Source context

Program Rust

parse_number

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

231 /// Try to parse a non-special floating point number,232 /// as well as two slices with integer and fractional parts233 /// and the parsed exponent.234 pub fn parse_number(s: &[u8]) -> Option<Decimal> {235     if let Some((float, rest)) = parse_partial_number(s) {236         if rest == s.len() {237             return Some(float);238         }239     }240     None241 }242 243 /// Try to parse a special, non-finite float.244 pub(crate) fn parse_inf_nan<F: Float>(s: &[u8], negative: bool) -> Option<F> {

Aeneas declaration

The Lean below was mechanically extracted by Aeneas from Rust.

def num.imp.dec2flt.parse.parse_number
  (s : Slice Std.U8) : Result (Option num.imp.dec2flt.decimal.Decimal) := do
  let o ← num.imp.dec2flt.parse.parse_partial_number s
  match o with
  | none => ok none
  | some p =>
    let (float, rest) := p
    let i := Slice.len s
    if rest = i
    then ok (some float)
    else ok none
Operations used here

Decimal · Program Rust

parse_partial_number · Program Rust

Source details
Declarationnum.imp.dec2flt.parse.parse_number
Filenum/imp/../../dec2flt/parse.rs
Lines234:0–241:1
Program versionRevised program