Source context

Program Rust

dec2flt

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

505 506 /// Converts a decimal string into a floating point number.507 #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above508 pub fn dec2flt<509     F: Lemire510         + core::ops::Div<Output = F>511         + core::ops::Mul<Output = F>512         + core::ops::Neg<Output = F>,513 >(514     s: &str,515 ) -> Result<F, ParseFloatError> {516     // `Lemire` already implies `Neg<Output = F>` through `Float`; the direct517     // clause admits exactly the same instances and lets Charon resolve the518     // explicit, source-equivalent final negation.519     // The public function is now exactly the result projection of the single520     // instrumented implementation.  No conversion step is duplicated, and521     // discarding the trace cannot affect Rust evaluation or the returned bits.522     dec2flt_with_trace::<F>(s).0523 }

Aeneas declaration

The Lean below was mechanically extracted by Aeneas from Rust.

def num.imp.dec2flt.dec2flt
  {F : Type} {Clause0_Clause0_Clause0_Int : Type} (LemireInst :
  num.imp.dec2flt.Lemire F Clause0_Clause0_Clause0_Int) (coreopsarithDivInst :
  core.ops.arith.Div F F F) (coreopsarithMulInst : core.ops.arith.Mul F F F)
  (coreopsarithNegInst : core.ops.arith.Neg F F) (s : Str) :
  Result (core.result.Result F num.float_parse.ParseFloatError)
  := do
  let (r, _) ←
    num.imp.dec2flt.dec2flt_with_trace LemireInst coreopsarithDivInst
      coreopsarithMulInst coreopsarithNegInst s
  ok r
Operations used here

Mul · Rust library

Div · Rust library

Neg · Rust library

Lemire · Program Rust

ParseFloatError · Program Rust

dec2flt_with_trace · Program Rust

Source details
Declarationnum.imp.dec2flt.dec2flt
Filenum/imp/../../dec2flt/mod.rs
Lines508:0–523:1
Program versionOriginal program