Trait bevy_reflect::Map
source · pub trait Map: Reflect {
fn get(&self, key: &dyn Reflect) -> Option<&dyn Reflect>;
fn get_mut(&mut self, key: &dyn Reflect) -> Option<&mut dyn Reflect>;
fn get_at(&self, index: usize) -> Option<(&dyn Reflect, &dyn Reflect)>;
fn len(&self) -> usize;
fn iter(&self) -> MapIter<'_> ⓘ;
fn drain(self: Box<Self>) -> Vec<(Box<dyn Reflect>, Box<dyn Reflect>)>;
fn clone_dynamic(&self) -> DynamicMap;
fn insert_boxed(
&mut self,
key: Box<dyn Reflect>,
value: Box<dyn Reflect>
) -> Option<Box<dyn Reflect>>;
fn is_empty(&self) -> bool { ... }
}
Expand description
An ordered mapping between Reflect
values.
Because the values are reflected, the underlying types of keys and values may differ between entries.
ReflectValue
Keys
are assumed to return a non-None
hash. The ordering
of Map
entries is not guaranteed to be stable across runs or between
instances.
This trait corresponds to types like std::collections::HashMap
.
Required Methods§
sourcefn get(&self, key: &dyn Reflect) -> Option<&dyn Reflect>
fn get(&self, key: &dyn Reflect) -> Option<&dyn Reflect>
Returns a reference to the value associated with the given key.
If no value is associated with key
, returns None
.
sourcefn get_mut(&mut self, key: &dyn Reflect) -> Option<&mut dyn Reflect>
fn get_mut(&mut self, key: &dyn Reflect) -> Option<&mut dyn Reflect>
Returns a mutable reference to the value associated with the given key.
If no value is associated with key
, returns None
.
sourcefn get_at(&self, index: usize) -> Option<(&dyn Reflect, &dyn Reflect)>
fn get_at(&self, index: usize) -> Option<(&dyn Reflect, &dyn Reflect)>
Returns the key-value pair at index
by reference, or None
if out of bounds.
sourcefn drain(self: Box<Self>) -> Vec<(Box<dyn Reflect>, Box<dyn Reflect>)>
fn drain(self: Box<Self>) -> Vec<(Box<dyn Reflect>, Box<dyn Reflect>)>
Drain the key-value pairs of this map to get a vector of owned values.
sourcefn clone_dynamic(&self) -> DynamicMap
fn clone_dynamic(&self) -> DynamicMap
Clones the map, producing a DynamicMap
.