Program Rust
parse_number
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
228 /// Try to parse a non-special floating point number,229 /// as well as two slices with integer and fractional parts230 /// and the parsed exponent.231 pub fn parse_number(s: &[u8]) -> Option<Decimal> {232 if let Some((float, rest)) = parse_partial_number(s) {233 if rest == s.len() {234 return Some(float);235 }236 }237 None238 }239 240 /// Try to parse a special, non-finite float.241 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 noneSource details
| Declaration | num.imp.dec2flt.parse.parse_number |
|---|---|
| File | num/imp/../../dec2flt/parse.rs |
| Lines | 231:0–238:1 |
| Program version | Original program |