Source context

Program Rust

adjust_many_digit_count

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

83 // Aeneas cannot join its loop context while the enclosing function's other84 // slice borrows are live.  It visits the same bytes, in order, and performs85 // the identical checked `isize` subtraction for every leading dot or zero.86 fn adjust_many_digit_count(start: &[u8], mut n_digits: isize) -> isize {87     let mut scan_index = 0;88     let mut scanning = true;89     while scan_index < start.len() && scanning {90         let c = start[scan_index];91         if c == b'.' || c == b'0' {92             n_digits -= c.saturating_sub(b'0' - 1) as isize;93             scan_index += 1;94         } else {95             scanning = false;96         }97     }98     n_digits99 }100 101 // This is the source many-digit retry as a transparent helper.  Isolating its102 // rebased slices avoids an Aeneas context-join failure; both calls, the branch,

Aeneas declaration

The Lean below was mechanically extracted by Aeneas from Rust.

@[reducible]
def num.imp.dec2flt.parse.adjust_many_digit_count
  (start : Slice Std.U8) (n_digits : Std.Isize) : Result Std.Isize := do
  num.imp.dec2flt.parse.adjust_many_digit_count_loop start n_digits 0#usize
    true
Operations used here

adjust_many_digit_count_loop · Program Rust

Source details
Declarationnum.imp.dec2flt.parse.adjust_many_digit_count
Filenum/imp/../../dec2flt/parse.rs
Lines86:0–99:1
Program versionOriginal program