From fa906d916d8d126d3cc3a2b4ab9a29fa27bee62d Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Tue, 27 Aug 2024 06:51:48 +0200 Subject: [PATCH] Add `SlotId::INVALID` --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index cf48253..b1647f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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); @@ -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 } }