Skip to main content

Entry

Enum Entry 

Source
pub enum Entry<'a, K: DirectKey, V, const PAGE: usize = DEFAULT_PAGE, D: Directory = Flat> {
    Occupied(OccupiedEntry<'a, K, V>),
    Vacant(VacantEntry<'a, K, V, PAGE, D>),
}
Expand description

A view into one key’s place in a PagedDirectMap, from entry.

Variants§

§

Occupied(OccupiedEntry<'a, K, V>)

The key is in the map.

§

Vacant(VacantEntry<'a, K, V, PAGE, D>)

The key is not in the map; its slot is empty or held by another generation of the key.

Implementations§

Source§

impl<'a, K: DirectKey, V, const PAGE: usize, D: Directory> Entry<'a, K, V, PAGE, D>

Source

pub fn key(&self) -> &K

The entry’s key: the stored key if occupied, else the key given to entry.

Source

pub fn or_insert(self, default: V) -> &'a mut V

The value, inserting default first if the key is absent (evicting another generation in its slot).

Source

pub fn or_insert_with(self, make: impl FnOnce() -> V) -> &'a mut V

The value, inserting make() first if the key is absent. make runs before the map changes, so if it panics the map is unchanged.

Source

pub fn or_insert_with_key(self, make: impl FnOnce(&K) -> V) -> &'a mut V

Like or_insert_with, but make is given the key.

Source

pub fn or_default(self) -> &'a mut V
where V: Default,

The value, inserting V::default() first if the key is absent.

Source

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.

Source

pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V>

Stores value for the key and returns the occupied entry. An occupied entry keeps its stored key; a vacant one evicts any other generation.

Trait Implementations§

Source§

impl<K: DirectKey + Debug, V: Debug, const PAGE: usize, D: Directory> Debug for Entry<'_, K, V, PAGE, D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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>
where OccupiedEntry<'a, K, V>: Freeze, VacantEntry<'a, K, V, PAGE, D>: Freeze,

§

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>: RefUnwindSafe, VacantEntry<'a, K, V, PAGE, D>: RefUnwindSafe,

§

impl<'a, K, V, const PAGE: usize, D> Send for Entry<'a, K, V, PAGE, D>
where OccupiedEntry<'a, K, V>: Send, VacantEntry<'a, K, V, PAGE, D>: Send,

§

impl<'a, K, V, const PAGE: usize, D> Sync for Entry<'a, K, V, PAGE, D>
where OccupiedEntry<'a, K, V>: Sync, VacantEntry<'a, K, V, PAGE, D>: Sync,

§

impl<'a, K, V, const PAGE: usize, D> Unpin for Entry<'a, K, V, PAGE, D>
where OccupiedEntry<'a, K, V>: Unpin, VacantEntry<'a, K, V, PAGE, D>: Unpin,

§

impl<'a, K, V, const PAGE: usize, D> UnsafeUnpin for Entry<'a, K, V, PAGE, D>
where OccupiedEntry<'a, K, V>: UnsafeUnpin, VacantEntry<'a, K, V, PAGE, D>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.