pub struct Index { /* private fields */ }Expand description
Stable handle into an Arena.
An Index is Copy, cheap to pass by value, and remains valid until the
element it points at is removed. Once removed, the handle becomes stale
and all lookups against the arena return None (or Error::StaleIndex
from fallible variants). Reusing the underlying slot under a new
generation does not revive the original handle.
§Layout
Index is 8 bytes (two u32s) and packs trivially into structs.
Implementations§
Source§impl Index
impl Index
Sourcepub const fn slot(self) -> u32
pub const fn slot(self) -> u32
Returns the slot number this handle points at.
Useful for diagnostics; do not use the slot number as a substitute for the handle itself — slots are reused under new generations.
Sourcepub const fn generation(self) -> u32
pub const fn generation(self) -> u32
Returns the generation counter recorded when this handle was issued.
Trait Implementations§
Source§impl Ord for Index
impl Ord for Index
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
Source§impl PartialOrd for Index
impl PartialOrd for Index
impl Copy for Index
impl Eq for Index
impl StructuralPartialEq for Index
Auto Trait Implementations§
impl Freeze for Index
impl RefUnwindSafe for Index
impl Send for Index
impl Sync for Index
impl Unpin for Index
impl UnsafeUnpin for Index
impl UnwindSafe for Index
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