Struct UniqueArena  
pub struct UniqueArena<T> { /* private fields */ }unstable-wgpu-27 only.Expand description
An arena whose elements are guaranteed to be unique.
A UniqueArena holds a set of unique values of type T, each with an
associated Span. Inserting a value returns a Handle<T>, which can be
used to index the UniqueArena and obtain shared access to the T element.
Access via a Handle is an array lookup - no hash lookup is necessary.
The element type must implement Eq and Hash. Insertions of equivalent
elements, according to Eq, all return the same Handle.
Once inserted, elements generally may not be mutated, although a replace
method exists to support rare cases.
UniqueArena is similar to Arena: If Arena is vector-like,
UniqueArena is HashSet-like.
Implementations§
§impl<T> UniqueArena<T>
 
impl<T> UniqueArena<T>
pub fn new() -> UniqueArena<T>
pub fn new() -> UniqueArena<T>
Create a new arena with no initial capacity allocated.
pub fn clear(&mut self)
pub fn clear(&mut self)
Clears the arena, keeping all allocations.
§impl<T> UniqueArena<T>
 
impl<T> UniqueArena<T>
pub fn iter(&self) -> impl DoubleEndedIterator + ExactSizeIterator
pub fn iter(&self) -> impl DoubleEndedIterator + ExactSizeIterator
Returns an iterator over the items stored in this arena, returning both the item’s handle and a reference to it.
pub fn insert(&mut self, value: T, span: Span) -> Handle<T>
pub fn insert(&mut self, value: T, span: Span) -> Handle<T>
Insert a new value into the arena.
Return a Handle<T>, which can be used to index this arena to get a
shared reference to the element.
If this arena already contains an element that is Eq to value,
return a Handle to the existing element, and drop value.
If value is inserted into the arena, associate span with
it. An element’s span can be retrieved with the get_span
method.
pub fn replace(&mut self, old: Handle<T>, new: T)
pub fn replace(&mut self, old: Handle<T>, new: T)
Replace an old value with a new value.
§Panics
- if the old value is not in the arena
- if the new value already exists in the arena
pub fn get(&self, value: &T) -> Option<Handle<T>>
pub fn get(&self, value: &T) -> Option<Handle<T>>
Return this arena’s handle for value, if present.
If this arena already contains an element equal to value,
return its handle. Otherwise, return None.
pub fn get_handle(&self, handle: Handle<T>) -> Result<&T, BadHandle>
pub fn get_handle(&self, handle: Handle<T>) -> Result<&T, BadHandle>
Return this arena’s value at handle, if that is a valid handle.
pub fn check_contains_handle(&self, handle: Handle<T>) -> Result<(), BadHandle>
pub fn check_contains_handle(&self, handle: Handle<T>) -> Result<(), BadHandle>
Assert that handle is valid for this arena.
Trait Implementations§
§impl<T> Clone for UniqueArena<T>where
    T: Clone,
 
impl<T> Clone for UniqueArena<T>where
    T: Clone,
§fn clone(&self) -> UniqueArena<T>
 
fn clone(&self) -> UniqueArena<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read more§impl<T> Debug for UniqueArena<T>
 
impl<T> Debug for UniqueArena<T>
§impl<T> Default for UniqueArena<T>
 
impl<T> Default for UniqueArena<T>
§fn default() -> UniqueArena<T>
 
fn default() -> UniqueArena<T>
§impl<T> Index<Handle<T>> for UniqueArena<T>
 
impl<T> Index<Handle<T>> for UniqueArena<T>
§impl TypeContext for UniqueArena<Type>
Format types as WGSL based on a UniqueArena<Type>.
 
impl TypeContext for UniqueArena<Type>
Format types as WGSL based on a UniqueArena<Type>.
This is probably only good enough for logging:
- 
It does not apply any kind of Namerrenamings.
- 
It generates invalid WGSL for anonymous struct types. 
- 
It doesn’t write override-sized arrays properly. 
§fn type_name(&self, handle: Handle<Type>) -> &str
 
fn type_name(&self, handle: Handle<Type>) -> &str
handle.§fn write_unnamed_struct<W>(
    &self,
    inner: &TypeInner,
    out: &mut W,
) -> Result<(), Error>where
    W: Write,
 
fn write_unnamed_struct<W>(
    &self,
    inner: &TypeInner,
    out: &mut W,
) -> Result<(), Error>where
    W: Write,
TypeInner::Struct for which we are unable to find a name. Read more§fn write_override<W>(
    &self,
    handle: Handle<Override>,
    out: &mut W,
) -> Result<(), Error>where
    W: Write,
 
fn write_override<W>(
    &self,
    handle: Handle<Override>,
    out: &mut W,
) -> Result<(), Error>where
    W: Write,
override to out.§fn write_non_wgsl_inner<W>(
    &self,
    inner: &TypeInner,
    out: &mut W,
) -> Result<(), Error>where
    W: Write,
 
fn write_non_wgsl_inner<W>(
    &self,
    inner: &TypeInner,
    out: &mut W,
) -> Result<(), Error>where
    W: Write,
§fn write_non_wgsl_scalar<W>(
    &self,
    scalar: Scalar,
    out: &mut W,
) -> Result<(), Error>where
    W: Write,
 
fn write_non_wgsl_scalar<W>(
    &self,
    scalar: Scalar,
    out: &mut W,
) -> Result<(), Error>where
    W: Write,
§fn write_type<W>(&self, handle: Handle<Type>, out: &mut W) -> Result<(), Error>where
    W: Write,
 
fn write_type<W>(&self, handle: Handle<Type>, out: &mut W) -> Result<(), Error>where
    W: Write,
ty as it would appear in a value’s declaration. Read more§fn write_type_inner<W>(
    &self,
    inner: &TypeInner,
    out: &mut W,
) -> Result<(), Error>where
    W: Write,
 
fn write_type_inner<W>(
    &self,
    inner: &TypeInner,
    out: &mut W,
) -> Result<(), Error>where
    W: Write,
§fn write_scalar<W>(&self, scalar: Scalar, out: &mut W) -> Result<(), Error>where
    W: Write,
 
fn write_scalar<W>(&self, scalar: Scalar, out: &mut W) -> Result<(), Error>where
    W: Write,
Scalar scalar as a WGSL type.§fn write_type_resolution<W>(
    &self,
    resolution: &TypeResolution,
    out: &mut W,
) -> Result<(), Error>where
    W: Write,
 
fn write_type_resolution<W>(
    &self,
    resolution: &TypeResolution,
    out: &mut W,
) -> Result<(), Error>where
    W: Write,
TypeResolution resolution as a WGSL type.fn write_type_conclusion<W>(
    &self,
    conclusion: &Conclusion,
    out: &mut W,
) -> Result<(), Error>where
    W: Write,
fn write_type_rule<W>(
    &self,
    name: &str,
    rule: &Rule,
    out: &mut W,
) -> Result<(), Error>where
    W: Write,
fn type_to_string(&self, handle: Handle<Type>) -> String
fn type_resolution_to_string(&self, resolution: &TypeResolution) -> String
fn type_rule_to_string(&self, name: &str, rule: &Rule) -> String
Auto Trait Implementations§
impl<T> Freeze for UniqueArena<T>
impl<T> RefUnwindSafe for UniqueArena<T>where
    T: RefUnwindSafe,
impl<T> Send for UniqueArena<T>where
    T: Send,
impl<T> Sync for UniqueArena<T>where
    T: Sync,
impl<T> Unpin for UniqueArena<T>where
    T: Unpin,
impl<T> UnwindSafe for UniqueArena<T>where
    T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
§impl<T> Downcast for Twhere
    T: Any,
 
impl<T> Downcast for Twhere
    T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
 
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
 
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
 
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
 
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
 
impl<T> DowncastSync for T
§impl<T> Instrument for T
 
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> NoneValue for Twhere
    T: Default,
 
impl<T> NoneValue for Twhere
    T: Default,
type NoneType = T
§fn null_value() -> T
 
fn null_value() -> T
§impl<T> Pointable for T
 
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
 
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
 
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().§impl<SS, SP> SupersetOf<SS> for SPwhere
    SS: SubsetOf<SP>,
 
impl<SS, SP> SupersetOf<SS> for SPwhere
    SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
 
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
 
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
 
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
 
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.