Program Rust
try_parse_digits_loop0
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
30 fn try_parse_digits(mut s: &[u8], mut x: u64) -> (&[u8], u64) {31 // may cause overflows, to be handled later32 33 while s.len() >= 8 {34 // `chunk` is the source's local `num` under a nonconflicting name.35 // The rename has no Rust effect and prevents the Lean backend from36 // resolving `num.imp...` as a field projection on this local value.37 let chunk = s.read_u64();38 if is_8digits(chunk) {39 x = x.wrapping_mul(1_0000_0000).wrapping_add(parse_8digits(chunk));40 s = &s[8..];41 } else {42 break;43 }44 }45 46 // This is the removed `ByteSlice::parse_digits` call specialized to its47 // only parser use: identical wrapping digit classification, accumulatorAeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
@[rust_loop]
def num.imp.dec2flt.parse.try_parse_digits_loop0
(s : Slice Std.U8) (x : Std.U64) : Result ((Slice Std.U8) × Std.U64) := do
loop
(fun (s1, x1) => num.imp.dec2flt.parse.try_parse_digits_loop0.body s1 x1)
(s, x)Operations used here
Other extracted objects at this span
Source details
| Declaration | num.imp.dec2flt.parse.try_parse_digits_loop0 |
|---|---|
| File | num/imp/../../dec2flt/parse.rs |
| Lines | 33:4–44:5 |
| Program version | Original program |