pub struct OrdDynMap<K, DynT>where
DynT: ?Sized,{ /* private fields */ }Implementations§
Source§impl<K, DynT> OrdDynMap<K, DynT>
impl<K, DynT> OrdDynMap<K, DynT>
Sourcepub fn insert<T>(&mut self, key: K, value: T) -> Result<DynKey<K, T>, T>where
DynT: MakeConcrete<T>,
pub fn insert<T>(&mut self, key: K, value: T) -> Result<DynKey<K, T>, T>where
DynT: MakeConcrete<T>,
Tries to insert a new value with provided key. If value with this key exists, returns Err with value, otherwise Ok containing the key.
Sourcepub unsafe fn insert_overwrite<T>(&mut self, key: K, value: T) -> DynKey<K, T>where
DynT: MakeConcrete<T>,
pub unsafe fn insert_overwrite<T>(&mut self, key: K, value: T) -> DynKey<K, T>where
DynT: MakeConcrete<T>,
Inserts the value with provided key, potentially overwriting previous value which can make earlier keys hold the wrong type.
This method can be more performant than standard insert.
SAFETY: You must ensure that you won’t acces this value with old key with incorrect binded type
Sourcepub fn get<T>(&self, key: &DynKey<K, T>) -> Option<&T>where
DynT: MakeConcrete<T>,
pub fn get<T>(&self, key: &DynKey<K, T>) -> Option<&T>where
DynT: MakeConcrete<T>,
Returns a reference to the value corresponding to the key and type bind
Sourcepub fn get_mut<T>(&mut self, key: &DynKey<K, T>) -> Option<&mut T>where
DynT: MakeConcrete<T>,
pub fn get_mut<T>(&mut self, key: &DynKey<K, T>) -> Option<&mut T>where
DynT: MakeConcrete<T>,
Returns a mutable reference to the value corresponding to the key and type bind
Sourcepub fn get_dyn(&self, key: &K) -> Option<&DynT>
pub fn get_dyn(&self, key: &K) -> Option<&DynT>
Returns a reference to the value corresponding to the key without concrete type
Sourcepub fn get_dyn_mut(&mut self, key: &K) -> Option<&mut DynT>
pub fn get_dyn_mut(&mut self, key: &K) -> Option<&mut DynT>
Returns a mutable reference to the value corresponding to the key without concrete type
Sourcepub fn iter(&self) -> impl Iterator<Item = (&K, &Box<DynT>)>
pub fn iter(&self) -> impl Iterator<Item = (&K, &Box<DynT>)>
Returns an iterator over references of entries of the map
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = (&K, &mut Box<DynT>)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&K, &mut Box<DynT>)>
Returns an iterator over mutable references of entries of the map
Sourcepub fn remove<T>(&mut self, key: &DynKey<K, T>) -> Option<Box<T>>where
DynT: MakeConcrete<T>,
pub fn remove<T>(&mut self, key: &DynKey<K, T>) -> Option<Box<T>>where
DynT: MakeConcrete<T>,
Removes the element with the given key from the map, returning its concrete type value if found
Sourcepub fn remove_dyn(&mut self, key: &K) -> Option<Box<DynT>>
pub fn remove_dyn(&mut self, key: &K) -> Option<Box<DynT>>
Removes the element with the given key from the map, returning corresponding trait object
Sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Returns whether the map contains an element with the given key