Program Rust
try_parse_digits_loop1
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
47 // only parser use: identical wrapping digit classification, accumulator48 // update, and first-nondigit stop, without an unsupported closure state.49 let mut count = 0;50 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {51 let digit = s[count].wrapping_sub(b'0');52 x = x.wrapping_mul(10).wrapping_add(digit as _);53 count += 1;54 }55 s = &s[count..];56 57 (s, x)Aeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
@[rust_loop]
def num.imp.dec2flt.parse.try_parse_digits_loop1
(s : Slice Std.U8) (x : Std.U64) (count : Std.Usize) :
Result (Std.U64 × Std.Usize)
:= do
loop
(fun (x1, count1) => num.imp.dec2flt.parse.try_parse_digits_loop1.body s x1
count1)
(x, count)Operations used here
Other extracted objects at this span
Source details
| Declaration | num.imp.dec2flt.parse.try_parse_digits_loop1 |
|---|---|
| File | num/imp/../../dec2flt/parse.rs |
| Lines | 50:4–54:5 |
| Program version | Original program |