pub struct Id<T> { /* private fields */ }Expand description
A typed, stable index into an Arena.
T is the referenced type and is used only as a marker; Id<T> has the
size of u32 and is Copy, Send, and Sync regardless of T. The
comparison, hashing, and formatting impls are implemented manually so they
never require T itself to implement them.
Implementations§
Source§impl<T> Id<T>
impl<T> Id<T>
Sourcepub const fn from_index(index: usize) -> Self
pub const fn from_index(index: usize) -> Self
Build an ID from an arena index.
This is the only way to construct an ID outside an arena. Prefer
Arena::push so the ID is valid by
construction; from_index exists for tests and deserialization paths
that then rely on bounds-checked lookup.
Trait Implementations§
impl<T> Copy for Id<T>
impl<T> Eq for Id<T>
Source§impl<T> Ord for Id<T>
impl<T> Ord for Id<T>
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
Auto Trait Implementations§
impl<T> Freeze for Id<T>
impl<T> RefUnwindSafe for Id<T>
impl<T> Send for Id<T>
impl<T> Sync for Id<T>
impl<T> Unpin for Id<T>
impl<T> UnsafeUnpin for Id<T>
impl<T> UnwindSafe for Id<T>
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