Struct naga::Arena

source ·
pub struct Arena<T> { /* private fields */ }
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§

Create a new arena with no initial capacity allocated.

Extracts the inner vector.

Returns the current number of items stored in this arena.

Returns true if the arena contains no elements.

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

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

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

Fetch a handle to an existing type.

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.

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

Get a mutable reference to an element in the arena.

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

Clears the arena keeping all allocations

Assert that handle is valid for this arena.

Assert that range is valid for this arena.

Trait Implementations§

Generate an arbitrary value of Self from the given unstructured data. Read more
Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.