pub trait Map: Reflect {
fn get(
&self,
key: &(dyn Reflect + 'static)
) -> Option<&(dyn Reflect + 'static)>;
fn get_mut(
&mut self,
key: &(dyn Reflect + 'static)
) -> Option<&mut (dyn Reflect + 'static)>;
fn get_at(
&self,
index: usize
) -> Option<(&(dyn Reflect + 'static), &(dyn Reflect + 'static))>;
fn len(&self) -> usize;
fn iter(&self) -> MapIter<'_> ⓘ;
fn drain(
self: Box<Self, Global>
) -> Vec<(Box<dyn Reflect + 'static, Global>, Box<dyn Reflect + 'static, Global>), Global> ⓘ;
fn clone_dynamic(&self) -> DynamicMap;
fn insert_boxed(
&mut self,
key: Box<dyn Reflect + 'static, Global>,
value: Box<dyn Reflect + 'static, Global>
) -> Option<Box<dyn Reflect + 'static, Global>>;
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§
fn get(&self, key: &(dyn Reflect + 'static)) -> Option<&(dyn Reflect + 'static)>
fn get(&self, key: &(dyn Reflect + 'static)) -> Option<&(dyn Reflect + 'static)>
Returns a reference to the value associated with the given key.
If no value is associated with key
, returns None
.
fn get_mut(
&mut self,
key: &(dyn Reflect + 'static)
) -> Option<&mut (dyn Reflect + 'static)>
fn get_mut(
&mut self,
key: &(dyn Reflect + 'static)
) -> Option<&mut (dyn Reflect + 'static)>
Returns a mutable reference to the value associated with the given key.
If no value is associated with key
, returns None
.
fn get_at(
&self,
index: usize
) -> Option<(&(dyn Reflect + 'static), &(dyn Reflect + 'static))>
fn get_at(
&self,
index: usize
) -> Option<(&(dyn Reflect + 'static), &(dyn Reflect + 'static))>
Returns the key-value pair at index
by reference, or None
if out of bounds.
fn drain(
self: Box<Self, Global>
) -> Vec<(Box<dyn Reflect + 'static, Global>, Box<dyn Reflect + 'static, Global>), Global> ⓘ
fn drain(
self: Box<Self, Global>
) -> Vec<(Box<dyn Reflect + 'static, Global>, Box<dyn Reflect + 'static, Global>), Global> ⓘ
Drain the key-value pairs of this map to get a vector of owned values.
fn clone_dynamic(&self) -> DynamicMap
fn clone_dynamic(&self) -> DynamicMap
Clones the map, producing a DynamicMap
.
fn insert_boxed(
&mut self,
key: Box<dyn Reflect + 'static, Global>,
value: Box<dyn Reflect + 'static, Global>
) -> Option<Box<dyn Reflect + 'static, Global>>
fn insert_boxed(
&mut self,
key: Box<dyn Reflect + 'static, Global>,
value: Box<dyn Reflect + 'static, Global>
) -> Option<Box<dyn Reflect + 'static, Global>>
Inserts a key-value pair into the map.
If the map did not have this key present, None
is returned.
If the map did have this key present, the value is updated, and the old value is returned.