pub struct Handle<T> { /* private fields */ }Expand description
A typed, generational reference to a value stored in a Pool<T>.
See the module docs for the representation and variance rationale.
Implementations§
Source§impl<T> Handle<T>
impl<T> Handle<T>
Sourcepub const fn generation(self) -> u32
pub const fn generation(self) -> u32
The generation this handle was issued with.
Never zero — see the module docs.
Sourcepub const fn to_bits(self) -> u64
pub const fn to_bits(self) -> u64
Packs the handle into a u64 (generation in the high half).
The packed form is stable and never zero, which makes it safe to use as
a wire/serialization representation with 0 reserved for “none”.
Sourcepub const fn from_bits(bits: u64) -> Option<Self>
pub const fn from_bits(bits: u64) -> Option<Self>
Unpacks a handle produced by Handle::to_bits.
Returns None if the generation half is zero, which no real handle ever
has.
Trait Implementations§
impl<T> Copy for Handle<T>
impl<T> Eq for Handle<T>
Auto Trait Implementations§
impl<T> Freeze for Handle<T>
impl<T> RefUnwindSafe for Handle<T>
impl<T> Send for Handle<T>
impl<T> Sync for Handle<T>
impl<T> Unpin for Handle<T>
impl<T> UnsafeUnpin for Handle<T>
impl<T> UnwindSafe for Handle<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