Source context

Program Rust

right_shift_loop2

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

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

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
Lines216:8–225:9
Program versionOriginal program