Struct zone_alloc::strong_registry::StrongRegistry
source · pub struct StrongRegistry<H, T> { /* private fields */ }Expand description
The same as Registry<T>, but with strongly-typed handles to prevent handles from being
shared across multiple registries.
The handle type must implement the StrongHandle trait.
Implementations§
source§impl<H, T> StrongRegistry<H, T>where
H: StrongHandle,
impl<H, T> StrongRegistry<H, T>where
H: StrongHandle,
sourcepub fn with_capacity(size: usize) -> Self
pub fn with_capacity(size: usize) -> Self
Creates a new strong registry with the given capacity.
sourcepub fn register(&self, value: T) -> H
pub fn register(&self, value: T) -> H
Registers a new value in the arena, returning a handle to that value.
sourcepub fn register_extend<I>(&self, iterable: I) -> (H, H)where
I: IntoIterator<Item = T>,
pub fn register_extend<I>(&self, iterable: I) -> (H, H)where
I: IntoIterator<Item = T>,
Registers the contents of an iterator in the registry.
Returns a numeric range of handles [a, b), where a is the handle of the first element
inserted and b is the handle after the last element inserted.
sourcepub fn reserve(&self, additional: usize)
pub fn reserve(&self, additional: usize)
Ensures there is enough continuous space for at least additional values.
sourcepub fn into_vec(self) -> Vec<T>
pub fn into_vec(self) -> Vec<T>
Converts the StrongRegistry<T> into a Vec<T>.
Items will maintain their handle as their vector index.
sourcepub fn iter(
&self
) -> impl Iterator<Item = Result<ElementRef<'_, T>, BorrowError>>
pub fn iter( &self ) -> impl Iterator<Item = Result<ElementRef<'_, T>, BorrowError>>
Returns an iterator that provides immutable access to all elements in the registry, in order of registration.
sourcepub fn iter_mut(
&mut self
) -> impl Iterator<Item = Result<ElementRefMut<'_, T>, BorrowError>>
pub fn iter_mut( &mut self ) -> impl Iterator<Item = Result<ElementRefMut<'_, T>, BorrowError>>
Returns an iterator that provides mutable access to all elements in the registry, in order of registration.
sourcepub fn get_unchecked(&self, handle: H) -> ElementRef<'_, T>
pub fn get_unchecked(&self, handle: H) -> ElementRef<'_, T>
Returns a reference to a value previously registered in the registry.
Panics if there is a borrow error.
sourcepub fn get(&self, handle: H) -> Result<ElementRef<'_, T>, BorrowError>
pub fn get(&self, handle: H) -> Result<ElementRef<'_, T>, BorrowError>
Tries to get a reference to a value previously registered in the registry.
sourcepub fn get_mut_unchecked(&self, handle: H) -> ElementRefMut<'_, T>
pub fn get_mut_unchecked(&self, handle: H) -> ElementRefMut<'_, T>
Returns a mutable reference to a value previously registered in the registry.
Panics if there is a borrow error.
sourcepub fn get_mut(&self, handle: H) -> Result<ElementRefMut<'_, T>, BorrowError>
pub fn get_mut(&self, handle: H) -> Result<ElementRefMut<'_, T>, BorrowError>
Tries to get a mutable reference to a value previously registered in the registry.