Struct naga::Arena[][src]

pub struct Arena<T> { /* fields omitted */ }

An arena holding some kind of component (e.g., type, constant, instruction, etc.) that can be referenced.

Adding new items to the arena produces a strongly-typed Handle. The arena can be indexed using the given handle to obtain a reference to the stored item.

Implementations

impl<T> Arena<T>[src]

pub fn new() -> Self[src]

Create a new arena with no initial capacity allocated.

pub fn len(&self) -> usize[src]

Returns the current number of items stored in this arena.

pub fn is_empty(&self) -> bool[src]

Returns true if the arena contains no elements.

pub fn iter(&self) -> impl DoubleEndedIterator<Item = (Handle<T>, &T)>[src]

Returns an iterator over the items stored in this arena, returning both the item's handle and a reference to it.

pub fn append(&mut self, value: T) -> Handle<T>[src]

Adds a new value to the arena, returning a typed handle.

The value is not linked to any SPIR-V module.

pub fn fetch_if<F: Fn(&T) -> bool>(&self, fun: F) -> Option<Handle<T>>[src]

Fetch a handle to an existing type.

pub fn fetch_if_or_append<F: Fn(&T, &T) -> bool>(
    &mut self,
    value: T,
    fun: F
) -> Handle<T>
[src]

Adds a value with a custom check for uniqueness: returns a handle pointing to an existing element if the check succeeds, or adds a new element otherwise.

pub fn fetch_or_append(&mut self, value: T) -> Handle<T> where
    T: PartialEq
[src]

Adds a value with a check for uniqueness, where the check is plain comparison.

pub fn try_get(&self, handle: Handle<T>) -> Option<&T>[src]

pub fn get_mut(&mut self, handle: Handle<T>) -> &mut T[src]

Get a mutable reference to an element in the arena.

Trait Implementations

impl<T: Debug> Debug for Arena<T>[src]

impl<T> Default for Arena<T>[src]

impl<T> Index<Handle<T>> for Arena<T>[src]

type Output = T

The returned type after indexing.

Auto Trait Implementations

impl<T> RefUnwindSafe for Arena<T> where
    T: RefUnwindSafe
[src]

impl<T> Send for Arena<T> where
    T: Send
[src]

impl<T> Sync for Arena<T> where
    T: Sync
[src]

impl<T> Unpin for Arena<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for Arena<T> where
    T: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.