pub struct HashDynMap<K, DynT, S = RandomState>where
DynT: ?Sized,{ /* private fields */ }Implementations§
Source§impl<K, DynT: ?Sized, S> HashDynMap<K, DynT, S>
impl<K, DynT: ?Sized, S> HashDynMap<K, DynT, S>
pub fn with_hasher(hash_state: S) -> Self
Source§impl<K, DynT> HashDynMap<K, DynT>
impl<K, DynT> HashDynMap<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
Trait Implementations§
Source§impl<K: Clone, DynT, S: Clone> Clone for HashDynMap<K, DynT, S>
impl<K: Clone, DynT, S: Clone> Clone for HashDynMap<K, DynT, S>
Source§fn clone(&self) -> HashDynMap<K, DynT, S>
fn clone(&self) -> HashDynMap<K, DynT, S>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more