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,

source

pub fn new() -> Self

Creates a new strong registry.

source

pub fn with_capacity(size: usize) -> Self

Creates a new strong registry with the given capacity.

source

pub fn len(&self) -> usize

Returns the number of elements owned by the strong registry.

source

pub fn register(&self, value: T) -> H

Registers a new value in the arena, returning a handle to that value.

source

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.

source

pub fn reserve(&self, additional: usize)

Ensures there is enough continuous space for at least additional values.

source

pub fn into_vec(self) -> Vec<T>

Converts the StrongRegistry<T> into a Vec<T>.

Items will maintain their handle as their vector index.

source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Returns an iterator that provides mutable access to all elements in the registry, in order of registration.

Registries only allow mutable iteration because the entire registry must be borrowed for the duration of the iteration. The mutable borrow to call this method allows Rust’s borrow checker to enforce this rule.

source

pub fn get_mut(&self, handle: H) -> Option<&mut T>

Returns a mutable reference to a value previously registered in the strong registry.

source

pub fn get(&self, handle: H) -> Option<&T>

Returns a reference to a value previously registered in the strong registry.

Auto Trait Implementations§

§

impl<H, T> !RefUnwindSafe for StrongRegistry<H, T>

§

impl<H, T> !Send for StrongRegistry<H, T>

§

impl<H, T> !Sync for StrongRegistry<H, T>

§

impl<H, T> Unpin for StrongRegistry<H, T>
where H: Unpin, T: Unpin,

§

impl<H, T> UnwindSafe for StrongRegistry<H, T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.