pub struct HandleAllocator<T> { /* private fields */ }Expand description
An allocator for generational handles.
Manages allocation and deallocation of handles, ensuring that stale handles are detected.
Implementations§
Source§impl<T> HandleAllocator<T>
impl<T> HandleAllocator<T>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an allocator with pre-allocated capacity.
Sourcepub fn deallocate(&mut self, handle: Handle<T>) -> Option<T>
pub fn deallocate(&mut self, handle: Handle<T>) -> Option<T>
Deallocates a handle, returning the value if the handle was valid.
Sourcepub fn get(&self, handle: Handle<T>) -> Option<&T>
pub fn get(&self, handle: Handle<T>) -> Option<&T>
Gets a reference to the value, if the handle is valid.
Sourcepub fn get_mut(&mut self, handle: Handle<T>) -> Option<&mut T>
pub fn get_mut(&mut self, handle: Handle<T>) -> Option<&mut T>
Gets a mutable reference to the value, if the handle is valid.
Sourcepub fn iter(&self) -> impl Iterator<Item = (Handle<T>, &T)>
pub fn iter(&self) -> impl Iterator<Item = (Handle<T>, &T)>
Iterates over all valid (handle, value) pairs.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = (Handle<T>, &mut T)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (Handle<T>, &mut T)>
Iterates over all valid (handle, value) pairs mutably.
Sourcepub fn values(&self) -> impl Iterator<Item = &T>
pub fn values(&self) -> impl Iterator<Item = &T>
Returns an iterator over all valid values (without handles).
Sourcepub fn values_mut(&mut self) -> impl Iterator<Item = &mut T>
pub fn values_mut(&mut self) -> impl Iterator<Item = &mut T>
Returns a mutable iterator over all valid values (without handles).
Source§impl<T: Send + Sync> HandleAllocator<T>
impl<T: Send + Sync> HandleAllocator<T>
Sourcepub fn par_values(&self) -> impl ParallelIterator<Item = &T>
pub fn par_values(&self) -> impl ParallelIterator<Item = &T>
Sourcepub fn par_values_mut(&mut self) -> impl ParallelIterator<Item = &mut T>
pub fn par_values_mut(&mut self) -> impl ParallelIterator<Item = &mut T>
Returns a parallel mutable iterator over all valid values.
Trait Implementations§
Source§impl<T: Debug> Debug for HandleAllocator<T>
impl<T: Debug> Debug for HandleAllocator<T>
Auto Trait Implementations§
impl<T> Freeze for HandleAllocator<T>
impl<T> RefUnwindSafe for HandleAllocator<T>where
T: RefUnwindSafe,
impl<T> Send for HandleAllocator<T>where
T: Send,
impl<T> Sync for HandleAllocator<T>where
T: Sync,
impl<T> Unpin for HandleAllocator<T>where
T: Unpin,
impl<T> UnwindSafe for HandleAllocator<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
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