pub trait AsLen: Sized + Copy {
// Required methods
spec fn as_nat(self) -> nat;
exec fn get(self) -> len : usize;
spec fn as_self(n: nat) -> Self;
proof fn lemma_lossless_casting(v: Self);
}Expand description
Types that can serve as format length (or count) fields.
The spec-facing conversion is to nat, which is the natural domain for lengths in proofs. The
exec-facing conversion is to usize, which is the natural domain for runtime indexing.
Required Methods§
Sourceexec fn get(self) -> len : usize
exec fn get(self) -> len : usize
ensures
len as nat == self.as_nat(),The runtime length represented by this value.
Sourceproof fn lemma_lossless_casting(v: Self)
proof fn lemma_lossless_casting(v: Self)
ensures
Self::as_self(v.as_nat()) == v,as_self(v.as_nat()) == v.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.