pub enum Entry<'v, T, K, V>{
Occupied(RawEntry<'v, T, K, V>),
Vacant(RawEntry<'v, T, K, V>),
}Expand description
Entry for an existing key-value pair in an ValordMap
or a vacant location to insert one.
Variants§
Occupied(RawEntry<'v, T, K, V>)
Existing slot with equivalent key.
Vacant(RawEntry<'v, T, K, V>)
Vacant slot (no equivalent key in the map).
Implementations§
Source§impl<'v, T, K, V> Entry<'v, T, K, V>
impl<'v, T, K, V> Entry<'v, T, K, V>
Sourcepub fn or_insert(&mut self, default: V) -> &mut V
pub fn or_insert(&mut self, default: V) -> &mut V
Inserts default value if the entry is vacant, and returns a mutable reference to the value.
§Examples
Sourcepub fn or_insert_with<F: FnOnce() -> V>(&mut self, default: F) -> &mut V
pub fn or_insert_with<F: FnOnce() -> V>(&mut self, default: F) -> &mut V
Inserts a value produced by the function default if the entry is vacant,
and returns a mutable reference to the value.
§Examples
Sourcepub fn or_insert_with_key<F: FnOnce(&K) -> V>(&mut self, default: F) -> &mut V
pub fn or_insert_with_key<F: FnOnce(&K) -> V>(&mut self, default: F) -> &mut V
Inserts a value produced by the function default with the given key if the entry is vacant,
and returns a mutable reference to the value.
§Examples
Sourcepub fn and_modify<F>(self, f: F) -> Self
pub fn and_modify<F>(self, f: F) -> Self
Modifies the entry if it is occupied with the function f, and returns the entry.
§Examples
Auto Trait Implementations§
impl<'v, T, K, V> Freeze for Entry<'v, T, K, V>
impl<'v, T, K, V> RefUnwindSafe for Entry<'v, T, K, V>
impl<'v, T, K, V> Send for Entry<'v, T, K, V>
impl<'v, T, K, V> Sync for Entry<'v, T, K, V>
impl<'v, T, K, V> Unpin for Entry<'v, T, K, V>
impl<'v, T, K, V> !UnwindSafe for Entry<'v, T, K, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more