Program Rust
body
This Rust is the input prepared for Aeneas. Modeling choices explains the adaptations from the production source.
103 let dp = self.decimal_point as usize;104 let mut n = 0_u64;105 106 for i in 0..dp {107 n *= 10;108 if i < self.num_digits {109 n += self.digits[i] as u64;110 }111 }112 113 let mut round_up = false;114 Aeneas declaration
The Lean below was mechanically extracted by Aeneas from Rust.
@[rust_loop_body]
def num.imp.dec2flt.decimal_seq.DecimalSeq.round_loop.body
(i : Std.Usize) (a : Array Std.U8 768#usize)
(iter : core.ops.range.Range Std.Usize) (n : Std.U64) :
Result (ControlFlow ((core.ops.range.Range Std.Usize) × Std.U64) Std.U64)
:= do
let (o, iter1) ←
core.iter.range.IteratorRange.next core.iter.range.StepUsize iter
match o with
| none => ok (done n)
| some i1 =>
let n1 ← n * 10#u64
if i1 < i
then
let i2 ← Array.index_usize a i1
let i3 ← lift (UScalar.cast .U64 i2)
let n2 ← n1 + i3
ok (cont (iter1, n2))
else ok (cont (iter1, n1))Other extracted objects at this span
Source details
| Declaration | num.imp.dec2flt.decimal_seq.DecimalSeq.round_loop.body |
|---|---|
| File | num/imp/../../dec2flt/decimal_seq.rs |
| Lines | 106:8–111:9 |
| Program version | Original program |