Enum agb_hashmap::Entry
source · pub enum Entry<'a, K: 'a, V: 'a, ALLOCATOR: Allocator = Global> {
Occupied(OccupiedEntry<'a, K, V, ALLOCATOR>),
Vacant(VacantEntry<'a, K, V, ALLOCATOR>),
}
Expand description
Variants§
Occupied(OccupiedEntry<'a, K, V, ALLOCATOR>)
An occupied entry
Vacant(VacantEntry<'a, K, V, ALLOCATOR>)
A vacant entry
Implementations§
source§impl<'a, K, V, ALLOCATOR: ClonableAllocator> Entry<'a, K, V, ALLOCATOR>where
K: Hash + Eq,
impl<'a, K, V, ALLOCATOR: ClonableAllocator> Entry<'a, K, V, ALLOCATOR>where K: Hash + Eq,
sourcepub fn or_insert(self, value: V) -> &'a mut V
pub fn or_insert(self, value: V) -> &'a mut V
Ensures a value is in the entry by inserting the given value, and returns a mutable reference to the value in the entry.
sourcepub fn or_insert_with<F>(self, f: F) -> &'a mut Vwhere
F: FnOnce() -> V,
pub fn or_insert_with<F>(self, f: F) -> &'a mut Vwhere F: FnOnce() -> V,
Ensures a value is in the entry by inserting the result of the function if empty, and returns a mutable reference to the value in the entry.
sourcepub fn or_insert_with_key<F>(self, f: F) -> &'a mut Vwhere
F: FnOnce(&K) -> V,
pub fn or_insert_with_key<F>(self, f: F) -> &'a mut Vwhere F: FnOnce(&K) -> V,
Ensures a value is in the entry by inserting the result of the function if empty, and returns a mutable reference to the value in the entry. This method allows for key-derived values for insertion by providing the function with a reference to the key.
The reference to the moved key is provided so that cloning or copying the key is unnecessary,
unlike with .or_insert_with(|| ...)
.
sourcepub fn and_modify<F>(self, f: F) -> Selfwhere
F: FnOnce(&mut V),
pub fn and_modify<F>(self, f: F) -> Selfwhere F: FnOnce(&mut V),
Provides in-place mutable access to an occupied entry before any potential inserts into the map.
sourcepub fn or_default(self) -> &'a mut Vwhere
V: Default,
pub fn or_default(self) -> &'a mut Vwhere V: Default,
Ensures a value is in th entry by inserting the default value if empty. Returns a mutable reference to the value in the entry.