Source context

Program Rust

ByteSlice

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

1 //! Common utilities, for internal use only.2 3 /// Helper methods to process immutable bytes.4 pub(crate) trait ByteSlice {5     /// Reads 8 bytes as a 64-bit integer in little-endian order.6     fn read_u64(&self) -> u64;7 8     /// Writes a 64-bit integer as 8 bytes in little-endian order.9     fn write_u64(&mut self, value: u64);10 11     /// Calculate the difference in length between two slices.12     fn offset_from(&self, other: &Self) -> isize;13 14 }15 16 impl ByteSlice for [u8] {17     #[inline(always)] // inlining this is crucial to remove bound checks

Aeneas declaration

The Lean below was mechanically extracted by Aeneas from Rust.

structure num.imp.dec2flt.common.ByteSlice (Self : Type) where
  read_u64 : Self → Result Std.U64
  write_u64 : Self → Std.U64 → Result Self
  offset_from : Self → Self → Result Std.Isize
Source details
Declarationnum.imp.dec2flt.common.ByteSlice
Filenum/imp/../../dec2flt/common.rs
Lines4:0–14:1
Program versionOriginal program