Enum prefix_trie::map::Entry
source · pub enum Entry<'a, P, T> {
Vacant(VacantEntry<'a, P, T>),
Occupied(OccupiedEntry<'a, P, T>),
}Expand description
A mutable view into a single entry in a map, which may either be vacant or occupied.
Variants§
Vacant(VacantEntry<'a, P, T>)
The entry is not present in the tree.
Occupied(OccupiedEntry<'a, P, T>)
The entry is already present in the tree.
Implementations§
source§impl<'a, P, T> Entry<'a, P, T>where
P: Prefix,
impl<'a, P, T> Entry<'a, P, T>where
P: Prefix,
sourcepub fn insert(self, v: T) -> Option<T>
pub fn insert(self, v: T) -> Option<T>
Replace the current entry, and return the entry that was stored before.
sourcepub fn or_insert(self, default: T) -> &'a mut T
pub fn or_insert(self, default: T) -> &'a mut T
Ensures a value is in the entry by inserting the default if empty, and returns a mutable reference to the value in the entry.
sourcepub fn or_insert_with<F: FnOnce() -> T>(self, default: F) -> &'a mut T
pub fn or_insert_with<F: FnOnce() -> T>(self, default: F) -> &'a mut T
Ensures a value is in the entry by inserting the result of the default function if empty, and returns a mutable reference to the value in the entry.
sourcepub fn and_modify<F: FnOnce(&mut T)>(self, f: F) -> Self
pub fn and_modify<F: FnOnce(&mut T)>(self, f: F) -> Self
Provides in-place mutable access to an occupied entry before any potential inserts into the map.