Source context

Program Rust

body

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

255 // parser context while retaining the same wrapping digit test and updates.256 fn parse_digits_into_seq<'a>(s: &'a [u8], d: &mut DecimalSeq) -> &'a [u8] {257     let mut count = 0;258     while count < s.len() && s[count].wrapping_sub(b'0') < 10 {259         let digit = s[count].wrapping_sub(b'0');260         d.try_add_digit(digit);261         count += 1;262     }263     &s[count..]264 }265 

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))
Operations used here

DecimalSeq · Program Rust

try_add_digit · Program Rust

Other extracted objects at this span

num.imp.dec2flt.decimal_seq.parse_digits_into_seq_loop

Source details
Declarationnum.imp.dec2flt.decimal_seq.parse_digits_into_seq_loop.body
Filenum/imp/../../dec2flt/decimal_seq.rs
Lines258:4–262:5
Program versionPreparation 1