Trait in_place::entry::KeyedOccupiedEntry
source · [−]pub trait KeyedOccupiedEntry<'c>: OccupiedEntry<'c> {
type Key: 'c;
type BorrowedKey: Borrow<Self::Key> + 'c;
fn get_pair<'e>(&'e self) -> (&'e Self::Key, &'e Self::Value)
where
'c: 'e;
fn get_pair_mut<'e>(&'e mut self) -> (&'e Self::Key, &'e mut Self::Value)
where
'c: 'e;
fn into_pair(self) -> (Self::BorrowedKey, &'c mut Self::Value);
}
Expand description
A trait to represent an occupied entry of a collection which owns its keys.
this can be thought of as holding a &K
, and a &mut V
into the collection.
Because indexed collections likely do not actually own the keys which are stored in them, BorrowedKey will be usize instead of &’c usize.
Associated Types
type BorrowedKey: Borrow<Self::Key> + 'c
Required methods
get the key value pair, immutably borrowed
get the key value pair. the key is immutably borrowed, and the value immutably.
note the lifetime of these borrows is independent from the entry.
only the value is allowed to be mutated, because mutating a key is likely to violate some invariants of the data structure.
convert the entry into key value pair. the key is immutably borrowed, and the value immutably.
note the lifetime of these borrows is the same as the destroyed entry.
only the value is allowed to be mutated, because mutating a key is likely to violate some invariants of the data structure.