Struct naga::Arena[][src]

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

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 into_inner(self) -> Vec<T>[src]

Extracts the inner vector.

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 iter_mut(
    &mut self
) -> impl DoubleEndedIterator<Item = (Handle<T>, &mut T)>
[src]

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

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

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

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.

pub fn range_from(&self, old_length: usize) -> Range<T>

Notable traits for Range<T>

impl<T> Iterator for Range<T> type Item = Handle<T>;
[src]

Get the range of handles from a particular number of elements to the end.

Trait Implementations

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

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

Formats the value using the given formatter. Read more

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

fn default() -> Self[src]

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

impl<'de, T> Deserialize<'de> for Arena<T> where
    T: Deserialize<'de>, 
[src]

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
    __D: Deserializer<'de>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

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

type Output = T

The returned type after indexing.

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

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

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

type Output = [T]

The returned type after indexing.

fn index(&self, range: Range<T>) -> &[T][src]

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

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

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
    __S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

impl<T> RefUnwindSafe for Arena<T> where
    T: RefUnwindSafe

impl<T> Send for Arena<T> where
    T: Send

impl<T> Sync for Arena<T> where
    T: Sync

impl<T> Unpin for Arena<T> where
    T: Unpin

impl<T> UnwindSafe for Arena<T> where
    T: UnwindSafe

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

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

Performs the conversion.

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.

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

Performs the conversion.

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]