pub struct SlotId(/* private fields */);Expand description
Stable handle into a SlotArena.
A lightweight identifier (wrapping a usize index) that provides O(1)
access to arena slots. Handles remain valid until the slot is removed;
after removal, the index may be reused by a later insert.
§Stability
Unlike raw indices or pointers, SlotId values are semantically tied to
the slot they reference. Accessing a removed slot returns None rather
than causing undefined behavior.
§Example
use cachekit::ds::SlotArena;
let mut arena = SlotArena::new();
let id = arena.insert(42);
// SlotId provides O(1) access
assert_eq!(arena.get(id), Some(&42));
// Inspect raw index for debugging
println!("Value stored at index {}", id.index());
// After removal, same index may be reused
arena.remove(id);
let new_id = arena.insert(100);
assert_eq!(id.index(), new_id.index());Implementations§
Trait Implementations§
impl Copy for SlotId
impl Eq for SlotId
impl StructuralPartialEq for SlotId
Auto Trait Implementations§
impl Freeze for SlotId
impl RefUnwindSafe for SlotId
impl Send for SlotId
impl Sync for SlotId
impl Unpin for SlotId
impl UnwindSafe for SlotId
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