Source context

Program Rust

write_u64

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

22     }23 24     #[inline(always)] // inlining this is crucial to remove bound checks25     fn write_u64(&mut self, value: u64) {26         self[..8].copy_from_slice(&value.to_le_bytes())27     }28 29     #[inline]30     fn offset_from(&self, other: &Self) -> isize {

Aeneas declaration

The Lean below was mechanically extracted by Aeneas from Rust.

def SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64
  (self : Slice Std.U8) (value : Std.U64) : Result (Slice Std.U8) := do
  let (s, index_mut_back) ←
    core.slice.index.Slice.index_mut
      (core.slice.index.SliceIndexRangeToUsizeSlice Std.U8) self
      { «end» := 8#usize }
  let a ← lift (core.num.U64.to_le_bytes value)
  let s1 ← lift (Array.to_slice a)
  let s2 ← core.slice.Slice.copy_from_slice core.marker.CopyU8 s s1
  ok (index_mut_back s2)
Source details
DeclarationSliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.write_u64
Filenum/imp/../../dec2flt/common.rs
Lines25:4–27:5
Program versionOriginal program