pub struct SparseSetId { /* private fields */ }Expand description
A clean dense id (generated by define_id*!): backing integer with
the MSB always clear (type invariant), naming a value in
[0, id_bound). The stolen MSB is available to Tagged consumers.
Implementations§
Source§impl SparseSetId
impl SparseSetId
Sourcepub fn new(n: u32) -> SparseSetId
pub fn new(n: u32) -> SparseSetId
Construct from a raw integer known to fit below the tag bit. Production parity: asserts at runtime (a verified caller has proven the range; an unverified one is trapped before an id with the tag bit set — violating the type invariant — could exist).
Trait Implementations§
Source§impl Clone for SparseSetId
impl Clone for SparseSetId
Source§fn clone(&self) -> SparseSetId
fn clone(&self) -> SparseSetId
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for SparseSetId
Source§impl Debug for SparseSetId
impl Debug for SparseSetId
Source§impl Default for SparseSetId
Default is id 0 (MSB clear ⟹ type invariant holds). Required by
semi-persistent containers indexing with this id: restore fills
reclaimed slots with Idx::default() before overwriting them.
impl Default for SparseSetId
Default is id 0 (MSB clear ⟹ type invariant holds). Required by
semi-persistent containers indexing with this id: restore fills
reclaimed slots with Idx::default() before overwriting them.
Source§fn default() -> SparseSetId
fn default() -> SparseSetId
Returns the “default value” for a type. Read more
Source§impl DenseId for SparseSetId
impl DenseId for SparseSetId
Source§type Index = u32
type Index = u32
Natural storage word for this id (production’s
DenseId::Index: u8, u16,
u32, or u64). This is the Word a NodeLayout stores keys as, and is
what makes the B+tree generic over the 31-bit (u32) and 63-bit (u64)
id families. Read moreSource§fn to_index(self) -> u32
fn to_index(self) -> u32
Exec: serialize the id to its storage word (production’s
Into<Self::Index>, used as key_to_word(k) = k.into()). The word’s
dense index equals the id’s, so ordering on words agrees with ordering
on ids; this is what lets the B+tree store and compare Index words
while reasoning about the abstract id_nat model.Source§fn from_usize(n: usize) -> SparseSetId
fn from_usize(n: usize) -> SparseSetId
Exec: construct from a
usize. Bounded IDs panic when
n >= id_bound() rather than narrowing or aliasing; use Self::try_new
at an untrusted capacity boundary. DenseUsize spans every usize, so
it round-trips unconditionally.Source§fn try_new(n: usize) -> Option<SparseSetId>
fn try_new(n: usize) -> Option<SparseSetId>
Exec: range-checked construction —
Some exactly on the representable
range. The primitive IdFactory allocates through (production’s
try_alloc checked the WORD range, not the id range, and would panic
half-way through the bit-stealing family’s word range; checking
id_bound here is the corrected contract).Source§fn bit_stealing() -> bool
fn bit_stealing() -> bool
Exec counterpart of
is_bit_stealing: a static
type property, so every impl is a literal and the check const-folds;
it exists so the B+tree’s total shell can refuse a non-bit-stealing
key at runtime instead of carrying a requires.Source§fn to_usize(self) -> usize
fn to_usize(self) -> usize
Production’s
DenseId::to_usize spelling (containers/src/dense_id.rs:23).
prod-parity: the consumer calls to_usize; verus’s own code uses
as_usize. Provided default delegates through the supertrait as_usize;
the bridge law reconciles its as_nat-stated ensures with id_nat.Source§impl Display for SparseSetId
impl Display for SparseSetId
impl Eq for SparseSetId
Source§impl Hash for SparseSetId
impl Hash for SparseSetId
Source§impl IndexLike for SparseSetId
impl IndexLike for SparseSetId
Source§fn min() -> SparseSetId
fn min() -> SparseSetId
Exec: zero / minimum value.
Source§fn max() -> SparseSetId
fn max() -> SparseSetId
Exec: maximum value.
Source§fn try_from_usize(n: usize) -> Option<SparseSetId>
fn try_from_usize(n: usize) -> Option<SparseSetId>
Exec: try to construct from a
usize. Succeeds iff n < max_nat().Source§fn lt(self, other: SparseSetId) -> bool
fn lt(self, other: SparseSetId) -> bool
Exec: less-than. Implemented via
as_usize round-trip on primitives.Source§fn le(self, other: SparseSetId) -> bool
fn le(self, other: SparseSetId) -> bool
Exec: less-than-or-equal.
Source§impl Ord for SparseSetId
impl Ord for SparseSetId
Source§fn cmp(&self, other: &SparseSetId) -> Ordering
fn cmp(&self, other: &SparseSetId) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for SparseSetId
impl PartialEq for SparseSetId
Source§impl PartialOrd for SparseSetId
impl PartialOrd for SparseSetId
Source§impl Tagged for SparseSetId
impl Tagged for SparseSetId
Source§impl TryFrom<u32> for SparseSetId
impl TryFrom<u32> for SparseSetId
Source§type Error = IdRangeError
type Error = IdRangeError
The type returned in the event of a conversion error.
Source§fn try_from(
raw: u32,
) -> Result<SparseSetId, <SparseSetId as TryFrom<u32>>::Error>
fn try_from( raw: u32, ) -> Result<SparseSetId, <SparseSetId as TryFrom<u32>>::Error>
Performs the conversion.
Auto Trait Implementations§
impl Freeze for SparseSetId
impl RefUnwindSafe for SparseSetId
impl Send for SparseSetId
impl Sync for SparseSetId
impl Unpin for SparseSetId
impl UnsafeUnpin for SparseSetId
impl UnwindSafe for SparseSetId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.