Program Rust
try_parse_19digits
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
58 }59 60 /// Parse up to 19 digits (the max that can be stored in a 64-bit integer).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 }81 82 // This is the source prefix scan isolated from `parse_partial_number` because83 // Aeneas cannot join its loop context while the enclosing function's otherAeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
@[reducible]
def num.imp.dec2flt.parse.try_parse_19digits
(s_ref : Slice Std.U8) (x : Std.U64) :
Result ((Slice Std.U8) × Std.U64)
:= do
num.imp.dec2flt.parse.try_parse_19digits_loop x s_refOperations used here
Source details
| Declaration | num.imp.dec2flt.parse.try_parse_19digits |
|---|---|
| File | num/imp/../../dec2flt/parse.rs |
| Lines | 61:0–80:1 |
| Program version | Original program |