Skip to content

Commit

Permalink
Add SlotId::INVALID
Browse files Browse the repository at this point in the history
  • Loading branch information
marc0246 committed Aug 27, 2024
1 parent bf52f0a commit fa906d9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,11 @@ pub struct SlotId {
}

impl SlotId {
pub const INVALID: Self = SlotId {
index: u32::MAX,
generation: NonZeroU32::MAX,
};

#[cfg(test)]
const fn new(index: u32, generation: u32) -> Self {
assert!(generation & OCCUPIED_BIT != 0);
Expand Down Expand Up @@ -1116,8 +1121,9 @@ impl SlotId {
}

#[inline(always)]
#[must_use]
pub const fn tag(self) -> u32 {
self.generation() & TAG_MASK
self.generation.get() & TAG_MASK
}
}

Expand Down

0 comments on commit fa906d9

Please sign in to comment.