pub enum OccupiedEntry<'a, K: 'a, V: 'a> {
HashMap(OccupiedHashMapEntry<'a, K, V>),
Vec(OccupiedVecEntry<'a, K, V>),
}Variants§
HashMap(OccupiedHashMapEntry<'a, K, V>)
Vec(OccupiedVecEntry<'a, K, V>)
Implementations§
Source§impl<'a, K, V> OccupiedEntry<'a, K, V>where
K: PrimInt,
V: PartialEq,
impl<'a, K, V> OccupiedEntry<'a, K, V>where
K: PrimInt,
V: PartialEq,
Sourcepub fn key(&self) -> K
pub fn key(&self) -> K
Returns this entry’s key.
§Example
let mut mule_map = mule_map::MuleMap::<u32, usize, fnv_rs::FnvBuildHasher>::new();
mule_map.entry(5).or_insert(12);
assert_eq!(mule_map.entry(5).key(), 5);Analogous to std::collections::hash_map::OccupiedEntry::key
Sourcepub fn remove_entry(self) -> (K, V)where
V: Clone,
pub fn remove_entry(self) -> (K, V)where
V: Clone,
Take the ownership of the key and value from the map.
§Example
let mut mule_map = mule_map::MuleMap::<u32, usize, fnv_rs::FnvBuildHasher>::new();
mule_map.entry(5).or_insert(12);
if let mule_map::Entry::Occupied(o) = mule_map.entry(5) {
o.remove_entry();
}
assert_eq!(mule_map.contains_key(5), false);Analogous to std::collections::hash_map::OccupiedEntry::remove_entry
Sourcepub fn get(&self) -> &V
pub fn get(&self) -> &V
Gets a reference to the value in the entry.
§Example
let mut mule_map = mule_map::MuleMap::<u32, usize, fnv_rs::FnvBuildHasher>::new();
mule_map.entry(5).or_insert(12);
if let mule_map::Entry::Occupied(o) = mule_map.entry(5) {
assert_eq!(o.get(), &12);
}Analogous to std::collections::hash_map::OccupiedEntry::get
Sourcepub fn get_mut(&mut self) -> &mut V
pub fn get_mut(&mut self) -> &mut V
Gets a mutable reference to the value in the entry.
If you need a reference to the OccupiedEntry which may outlive the destruction of the Entry value, see
OccupiedEntry::into_mut.
§Example
let mut mule_map = mule_map::MuleMap::<u32, usize, fnv_rs::FnvBuildHasher>::new();
mule_map.entry(5).or_insert(12);
if let mule_map::Entry::Occupied(mut o) = mule_map.entry(5) {
*o.get_mut() += 10;
assert_eq!(o.get(), &22);
*o.get_mut() += 2;
}
assert_eq!(mule_map.get(5), Some(&24));Analogous to std::collections::hash_map::OccupiedEntry::get_mut
Sourcepub fn into_mut(self) -> &'a mut V
pub fn into_mut(self) -> &'a mut V
Converts the OccupiedEntry into a mutable reference to the value in the entry with a lifetime bound to the
map itself.
If you need multiple references to the OccupiedEntry, see OccupiedEntry::get_mut.
§Example
let mut mule_map = mule_map::MuleMap::<u32, usize, fnv_rs::FnvBuildHasher>::new();
mule_map.entry(5).or_insert(12);
if let mule_map::Entry::Occupied(mut o) = mule_map.entry(5) {
*o.into_mut() += 10;
}
assert_eq!(mule_map.get(5), Some(&22));Analogous to std::collections::hash_map::OccupiedEntry::into_mut
Sourcepub fn insert(&mut self, value: V) -> V
pub fn insert(&mut self, value: V) -> V
Sets the value of the entry, and returns the entry’s old value.
§Example
let mut mule_map = mule_map::MuleMap::<u32, usize, fnv_rs::FnvBuildHasher>::new();
mule_map.entry(5).or_insert(12);
if let mule_map::Entry::Occupied(mut o) = mule_map.entry(5) {
assert_eq!(o.insert(15), 12);
}
assert_eq!(mule_map.get(5), Some(&15));Analogous to std::collections::hash_map::OccupiedEntry::insert
Sourcepub fn remove(self) -> Vwhere
V: Clone,
pub fn remove(self) -> Vwhere
V: Clone,
Takes the value out of the entry, and returns it.
§Example
let mut mule_map = mule_map::MuleMap::<u32, usize, fnv_rs::FnvBuildHasher>::new();
mule_map.entry(5).or_insert(12);
if let mule_map::Entry::Occupied(mut o) = mule_map.entry(5) {
assert_eq!(o.remove(), 12);
}
assert_eq!(mule_map.contains_key(5), false);Analogous to std::collections::hash_map::OccupiedEntry::remove