Program Rust
body
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
256 // parser context while retaining the same wrapping digit test and updates.257 fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {258 let mut count = 0;259 while count < s.len() && s[count].wrapping_sub(b'0') < 10 {260 let digit = s[count].wrapping_sub(b'0');261 d.try_add_digit(digit);262 count += 1;263 }264 &s[count..]265 }266 Aeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
@[rust_loop_body]
def num.imp.dec2flt.decimal_seq.parse_digits_into_seq_loop.body
(s : Slice Std.U8) (d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(count : Std.Usize) :
Result (ControlFlow (num.imp.dec2flt.decimal_seq.DecimalSeq × Std.Usize)
(num.imp.dec2flt.decimal_seq.DecimalSeq × Std.Usize))
:= do
let i := Slice.len s
if count < i
then
let i1 ← Slice.index_usize s count
let i2 ← lift (core.num.U8.wrapping_sub i1 48#u8)
if i2 < 10#u8
then
let digit ← lift (core.num.U8.wrapping_sub i1 48#u8)
let d1 ← num.imp.dec2flt.decimal_seq.DecimalSeq.try_add_digit d digit
let count1 ← count + 1#usize
ok (cont (d1, count1))
else ok (done (d, count))
else ok (done (d, count))Other extracted objects at this span
Source details
| Declaration | num.imp.dec2flt.decimal_seq.parse_digits_into_seq_loop.body |
|---|---|
| File | num/imp/../../dec2flt/decimal_seq.rs |
| Lines | 259:4–263:5 |
| Program version | Revised program |