Source context

Program Rust

count_trailing_zeros

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

233 // It is separate because Aeneas cannot join the loop while `parse_decimal_seq`234 // retains its other slice borrows.  The downward index has the same visitation235 // order and counts precisely the same zero bytes while ignoring dots.236 fn count_trailing_zeros(start: &[u8], consumed_len: usize) -> usize {237     let mut n_trailing_zeros = 0;238     let mut i = consumed_len;239     let mut scanning = true;240     while i != 0 && scanning {241         let c = start[i - 1];242         if c == b'0' || c == b'.' {243             i -= 1;244             if c == b'0' {245                 n_trailing_zeros += 1;246             }247         } else {248             scanning = false;249         }250     }251     n_trailing_zeros252 }253 254 // Equivalent to `ByteSlice::parse_digits(|digit| d.try_add_digit(digit))`.255 // An explicit index keeps the closure's mutable borrow out of the enclosing

Aeneas declaration

The Lean below was mechanically extracted by Aeneas from Rust.

@[reducible]
def num.imp.dec2flt.decimal_seq.count_trailing_zeros
  (start : Slice Std.U8) (consumed_len : Std.Usize) : Result Std.Usize := do
  num.imp.dec2flt.decimal_seq.count_trailing_zeros_loop start 0#usize
    consumed_len true
Operations used here

count_trailing_zeros_loop · Program Rust

Source details
Declarationnum.imp.dec2flt.decimal_seq.count_trailing_zeros
Filenum/imp/../../dec2flt/decimal_seq.rs
Lines236:0–252:1
Program versionRevised program