Struct naga::arena::handlevec::HandleVec

source ·
pub(crate) struct HandleVec<T, U> {
    inner: Vec<U>,
    as_keys: PhantomData<T>,
}
Expand description

A Vec indexed by Handles.

A HandleVec<T, U> is a Vec<U> indexed by values of type Handle<T>, rather than usize.

Rather than a push method, HandleVec has an insert method, analogous to HashMap::insert, that requires you to provide the handle at which the new value should appear. However, since HandleVec only supports insertion at the end, the given handle’s index must be equal to the the HandleVec’s current length; otherwise, the insertion will panic.

Fields§

§inner: Vec<U>§as_keys: PhantomData<T>

Implementations§

source§

impl<T, U> HandleVec<T, U>

source

pub(crate) const fn new() -> Self

source

pub(crate) fn with_capacity(capacity: usize) -> Self

source

pub(crate) fn len(&self) -> usize

source

pub(crate) fn insert(&mut self, handle: Handle<T>, value: U)

Insert a mapping from handle to value.

Unlike a HashMap, a HandleVec can only have new entries inserted at the end, like Vec::push. So the index of handle must equal self.len().

source

pub(crate) fn get(&self, handle: Handle<T>) -> Option<&U>

source

pub(crate) fn clear(&mut self)

source

pub(crate) fn resize(&mut self, len: usize, fill: U)
where U: Clone,

source

pub(crate) fn iter(&self) -> impl Iterator<Item = &U>

source

pub(crate) fn iter_mut(&mut self) -> impl Iterator<Item = &mut U>

Trait Implementations§

source§

impl<T: Debug, U: Debug> Debug for HandleVec<T, U>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T, U> Default for HandleVec<T, U>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T, U> Index<Handle<T>> for HandleVec<T, U>

§

type Output = U

The returned type after indexing.
source§

fn index(&self, handle: Handle<T>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<T, U> IndexMut<Handle<T>> for HandleVec<T, U>

source§

fn index_mut(&mut self, handle: Handle<T>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<K, V> Recyclable for HandleVec<K, V>

source§

fn recycle(self) -> Self

Clear self, retaining its current memory allocations. Read more

Auto Trait Implementations§

§

impl<T, U> Freeze for HandleVec<T, U>

§

impl<T, U> RefUnwindSafe for HandleVec<T, U>

§

impl<T, U> Send for HandleVec<T, U>
where T: Send, U: Send,

§

impl<T, U> Sync for HandleVec<T, U>
where T: Sync, U: Sync,

§

impl<T, U> Unpin for HandleVec<T, U>
where T: Unpin, U: Unpin,

§

impl<T, U> UnwindSafe for HandleVec<T, U>
where T: UnwindSafe, U: UnwindSafe,

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.