pub struct Handle<T> { /* private fields */ }Expand description
A generational index handle.
The handle contains:
- An index into a resource array
- A generation counter to detect stale references
- A phantom type marker for type safety
Implementations§
Source§impl<T> Handle<T>
impl<T> Handle<T>
Sourcepub const fn new(index: u32, generation: u32) -> Self
pub const fn new(index: u32, generation: u32) -> Self
Creates a new handle with the given index and generation.
Sourcepub const fn generation(self) -> u32
pub const fn generation(self) -> u32
Returns the generation portion of the handle.
Sourcepub const fn dangling() -> Self
pub const fn dangling() -> Self
Creates a dangling handle that doesn’t point to any valid resource.
Sourcepub const fn is_dangling(self) -> bool
pub const fn is_dangling(self) -> bool
Checks if this handle is dangling.
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>where
T: RefUnwindSafe,
impl<T> Send for Handle<T>where
T: Send,
impl<T> Sync for Handle<T>where
T: Sync,
impl<T> Unpin for Handle<T>where
T: Unpin,
impl<T> UnwindSafe for Handle<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more