pub enum Entry<'a, K: Key, V, const PAGE: usize = DEFAULT_PAGE, D: Directory = Flat> {
Occupied(OccupiedEntry<'a, K, V, PAGE, D>),
Vacant(VacantEntry<'a, K, V, PAGE, D>),
}Expand description
A view into one key’s place in a PagedSparseMap, from
PagedSparseMap::entry.
Variants§
Occupied(OccupiedEntry<'a, K, V, PAGE, D>)
The key is in the map.
Vacant(VacantEntry<'a, K, V, PAGE, D>)
The key’s slot is empty or held by another generation.
Implementations§
Source§impl<'a, K: Key, V, const PAGE: usize, D: Directory> Entry<'a, K, V, PAGE, D>
impl<'a, K: Key, V, const PAGE: usize, D: Directory> Entry<'a, K, V, PAGE, D>
Sourcepub fn key(&self) -> &K
pub fn key(&self) -> &K
The stored key if occupied, or the key given to PagedSparseMap::entry.
Sourcepub fn or_insert(self, default: V) -> &'a mut V
pub fn or_insert(self, default: V) -> &'a mut V
The value, inserting default first if the key is absent.
Sourcepub fn or_insert_with(self, make: impl FnOnce() -> V) -> &'a mut V
pub fn or_insert_with(self, make: impl FnOnce() -> V) -> &'a mut V
The value, inserting make() first if the key is absent. If make
panics, the map is unchanged.
Sourcepub fn or_insert_with_key(self, make: impl FnOnce(&K) -> V) -> &'a mut V
pub fn or_insert_with_key(self, make: impl FnOnce(&K) -> V) -> &'a mut V
Like or_insert_with, giving make the key.
Sourcepub fn or_default(self) -> &'a mut Vwhere
V: Default,
pub fn or_default(self) -> &'a mut Vwhere
V: Default,
The value, inserting V::default() first if the key is absent.
Sourcepub fn and_modify(self, f: impl FnOnce(&mut V)) -> Self
pub fn and_modify(self, f: impl FnOnce(&mut V)) -> Self
Calls f on the value if the key is present, and returns the entry.
Sourcepub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V, PAGE, D>
pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V, PAGE, D>
Stores value for the key and returns the occupied entry. An occupied
entry keeps its stored key. Inserting into a vacant entry evicts any
other generation in the slot.
Trait Implementations§
Auto Trait Implementations§
impl<'a, K, V, const PAGE: usize = DEFAULT_PAGE, D = Flat> !UnwindSafe for Entry<'a, K, V, PAGE, D>
impl<'a, K, V, const PAGE: usize, D> Forget for Entry<'a, K, V, PAGE, D>
impl<'a, K, V, const PAGE: usize, D> Freeze for Entry<'a, K, V, PAGE, D>
impl<'a, K, V, const PAGE: usize, D> Move for Entry<'a, K, V, PAGE, D>
impl<'a, K, V, const PAGE: usize, D> RefUnwindSafe for Entry<'a, K, V, PAGE, D>where
OccupiedEntry<'a, K, V, PAGE, D>: RefUnwindSafe,
VacantEntry<'a, K, V, PAGE, D>: RefUnwindSafe,
impl<'a, K, V, const PAGE: usize, D> Send for Entry<'a, K, V, PAGE, D>
impl<'a, K, V, const PAGE: usize, D> Sync for Entry<'a, K, V, PAGE, D>
impl<'a, K, V, const PAGE: usize, D> Unpin for Entry<'a, K, V, PAGE, D>
impl<'a, K, V, const PAGE: usize, D> UnsafeUnpin for Entry<'a, K, V, PAGE, D>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more