Source context

Program Rust

right_shift_loop2

This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.

214             self.digits[write_index] = new_digit;215             write_index += 1;216         }217         while n > 0 {218             let new_digit = (n >> shift) as u8;219             n = 10 * (n & mask);220             if write_index < Self::MAX_DIGITS {221                 self.digits[write_index] = new_digit;222                 write_index += 1;223             } else if new_digit > 0 {224                 self.truncated = true;225             }226         }227         self.num_digits = write_index;228         self.trim();229     }

Aeneas declaration

The Lean below was mechanically extracted by Aeneas from Rust.

@[rust_loop]
def num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
  (b : Bool) (a : Array Std.U8 768#usize) (shift : Std.Usize)
  (write_index : Std.Usize) (n : Std.U64) (mask : Std.U64) :
  Result (Bool × (Array Std.U8 768#usize) × Std.Usize)
  := do
  loop
    (fun (b1, a1, write_index1, n1) =>
      num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2.body shift mask
      b1 a1 write_index1 n1)
    (b, a, write_index, n)
Operations used here

body · Program Rust

Other extracted objects at this span

num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2.body

Source details
Declarationnum.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
Filenum/imp/../../dec2flt/decimal_seq.rs
Lines217:8–226:9
Program versionRevised program