Source context

Program Rust

try_parse_19digits_loop

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

61 fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {62     let mut s = *s_ref;63 64     while *x < MIN_19DIGIT_INT {65         if let Some((c, s_next)) = s.split_first() {66             let digit = c.wrapping_sub(b'0');67 68             if digit < 10 {69                 *x = (*x * 10) + digit as u64; // no overflows here70                 s = s_next;71             } else {72                 break;73             }74         } else {75             break;76         }77     }78 79     *s_ref = s;80 }

Aeneas declaration

The Lean below was mechanically extracted by Aeneas from Rust.

@[rust_loop]
def num.imp.dec2flt.parse.try_parse_19digits_loop
  (x : Std.U64) (s : Slice Std.U8) : Result ((Slice Std.U8) × Std.U64) := do
  loop
    (fun (x1, s1) => num.imp.dec2flt.parse.try_parse_19digits_loop.body x1 s1)
    (x, s)
Operations used here

body · Program Rust

Other extracted objects at this span

num.imp.dec2flt.parse.try_parse_19digits_loop.body

Source details
Declarationnum.imp.dec2flt.parse.try_parse_19digits_loop
Filenum/imp/../../dec2flt/parse.rs
Lines64:4–77:5
Program versionOriginal program