Source context

Program Rust

parse_scientific_loop

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

139         // exactly once per accepted byte and the bound keeps every checked140         // exponent operation in the same safe range as the source.141         let mut count = 0;142         while count < s.len() && s[count].wrapping_sub(b'0') < 10 {143             let digit = s[count].wrapping_sub(b'0');144             if exponent < 0x10000 {145                 exponent = 10 * exponent + digit as i64;146             }147             count += 1;148         }149         *s_ref = &s[count..];150         if negative { Some(-exponent) } else { Some(exponent) }151     } else {

Aeneas declaration

The Lean below was mechanically extracted by Aeneas from Rust.

@[rust_loop]
def num.imp.dec2flt.parse.parse_scientific_loop
  (exponent : Std.I64) (s : Slice Std.U8) (count : Std.Usize) :
  Result (Std.I64 × Std.Usize)
  := do
  loop
    (fun (exponent1, count1) =>
      num.imp.dec2flt.parse.parse_scientific_loop.body s exponent1 count1)
    (exponent, count)
Operations used here

body · Program Rust

Other extracted objects at this span

num.imp.dec2flt.parse.parse_scientific_loop.body

Source details
Declarationnum.imp.dec2flt.parse.parse_scientific_loop
Filenum/imp/../../dec2flt/parse.rs
Lines142:8–148:9
Program versionOriginal program