pub struct Arena<T> { /* private fields */ }
wgpu_core
or naga
only.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§
source§impl<T> Arena<T>
impl<T> Arena<T>
sourcepub const fn new() -> Arena<T>
Available on wgpu_core
only.
pub const fn new() -> Arena<T>
wgpu_core
only.Create a new arena with no initial capacity allocated.
sourcepub fn into_inner(self) -> Vec<T>
Available on wgpu_core
only.
pub fn into_inner(self) -> Vec<T>
wgpu_core
only.Extracts the inner vector.
sourcepub fn len(&self) -> usize
Available on wgpu_core
only.
pub fn len(&self) -> usize
wgpu_core
only.Returns the current number of items stored in this arena.
sourcepub fn is_empty(&self) -> bool
Available on wgpu_core
only.
pub fn is_empty(&self) -> bool
wgpu_core
only.Returns true
if the arena contains no elements.
sourcepub fn iter(&self) -> impl DoubleEndedIterator
Available on wgpu_core
only.
pub fn iter(&self) -> impl DoubleEndedIterator
wgpu_core
only.Returns an iterator over the items stored in this arena, returning both the item’s handle and a reference to it.
sourcepub fn drain(&mut self) -> impl DoubleEndedIterator
Available on wgpu_core
only.
pub fn drain(&mut self) -> impl DoubleEndedIterator
wgpu_core
only.Drains the arena, returning an iterator over the items stored.
sourcepub fn iter_mut(&mut self) -> impl DoubleEndedIterator
Available on wgpu_core
only.
pub fn iter_mut(&mut self) -> impl DoubleEndedIterator
wgpu_core
only.Returns a iterator over the items stored in this arena, returning both the item’s handle and a mutable reference to it.
sourcepub fn append(&mut self, value: T, span: Span) -> Handle<T>
Available on wgpu_core
only.
pub fn append(&mut self, value: T, span: Span) -> Handle<T>
wgpu_core
only.Adds a new value to the arena, returning a typed handle.
sourcepub fn fetch_if<F>(&self, fun: F) -> Option<Handle<T>>
Available on wgpu_core
only.
pub fn fetch_if<F>(&self, fun: F) -> Option<Handle<T>>
wgpu_core
only.Fetch a handle to an existing type.
sourcepub fn fetch_if_or_append<F>(
&mut self,
value: T,
span: Span,
fun: F
) -> Handle<T>
Available on wgpu_core
only.
pub fn fetch_if_or_append<F>( &mut self, value: T, span: Span, fun: F ) -> Handle<T>
wgpu_core
only.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.
sourcepub fn fetch_or_append(&mut self, value: T, span: Span) -> Handle<T>where
T: PartialEq,
Available on wgpu_core
only.
pub fn fetch_or_append(&mut self, value: T, span: Span) -> Handle<T>where
T: PartialEq,
wgpu_core
only.Adds a value with a check for uniqueness, where the check is plain comparison.
pub fn try_get(&self, handle: Handle<T>) -> Result<&T, BadHandle>
wgpu_core
only.sourcepub fn get_mut(&mut self, handle: Handle<T>) -> &mut T
Available on wgpu_core
only.
pub fn get_mut(&mut self, handle: Handle<T>) -> &mut T
wgpu_core
only.Get a mutable reference to an element in the arena.
sourcepub fn range_from(&self, old_length: usize) -> Range<T> ⓘ
Available on wgpu_core
only.
pub fn range_from(&self, old_length: usize) -> Range<T> ⓘ
wgpu_core
only.Get the range of handles from a particular number of elements to the end.
pub fn get_span(&self, handle: Handle<T>) -> Span
wgpu_core
only.sourcepub fn check_contains_handle(&self, handle: Handle<T>) -> Result<(), BadHandle>
Available on wgpu_core
only.
pub fn check_contains_handle(&self, handle: Handle<T>) -> Result<(), BadHandle>
wgpu_core
only.Assert that handle
is valid for this arena.
sourcepub fn check_contains_range(
&self,
range: &Range<T>
) -> Result<(), BadRangeError>
Available on wgpu_core
only.
pub fn check_contains_range( &self, range: &Range<T> ) -> Result<(), BadRangeError>
wgpu_core
only.Assert that range
is valid for this arena.
Trait Implementations§
source§impl<'arbitrary, T> Arbitrary<'arbitrary> for Arena<T>where
T: Arbitrary<'arbitrary>,
impl<'arbitrary, T> Arbitrary<'arbitrary> for Arena<T>where
T: Arbitrary<'arbitrary>,
source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Arena<T>, Error>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Arena<T>, Error>
Self
from the given unstructured data. Read moresource§impl<'de, T> Deserialize<'de> for Arena<T>where
T: Deserialize<'de>,
Available on crate feature deserialize
only.
impl<'de, T> Deserialize<'de> for Arena<T>where
T: Deserialize<'de>,
deserialize
only.