Enum Entry

Source
pub enum Entry<'a, T, Extractor, K, S = DefaultHashBuilder> {
    Vacant(VacantEntry<'a, T, Extractor, K, S>),
    OccupiedEntry(&'a mut T),
}
Expand description

An entry into a KeyedSet, allowing in-place modification of the value associated with the key if it exists.

Variants§

§

Vacant(VacantEntry<'a, T, Extractor, K, S>)

The key was not yet present in the KeyedSet.

§

OccupiedEntry(&'a mut T)

The key was already present in the KeyedSet.

Implementations§

Source§

impl<'a, T: 'a, Extractor, S, K> Entry<'a, T, Extractor, K, S>
where S: BuildHasher, for<'z> Extractor: KeyExtractor<'z, T>, for<'z, 'b> <Extractor as KeyExtractor<'z, T>>::Key: PartialEq<<Extractor as KeyExtractor<'b, T>>::Key>,

Source

pub fn get_or_insert_with(self, f: impl FnOnce(K) -> T) -> &'a mut T

Get a mutable reference to the value if present, or assign a value constructed by f if it wasn’t.

Source

pub fn get_or_insert_with_into(self) -> &'a mut T
where K: Into<T>,

A shortcut for entry.get_or_insert_with(Into::into)

Auto Trait Implementations§

§

impl<'a, T, Extractor, K, S> Freeze for Entry<'a, T, Extractor, K, S>
where K: Freeze,

§

impl<'a, T, Extractor, K, S> RefUnwindSafe for Entry<'a, T, Extractor, K, S>

§

impl<'a, T, Extractor, K, S> Send for Entry<'a, T, Extractor, K, S>
where K: Send, T: Send, S: Send, Extractor: Send,

§

impl<'a, T, Extractor, K, S> Sync for Entry<'a, T, Extractor, K, S>
where K: Sync, T: Sync, S: Sync, Extractor: Sync,

§

impl<'a, T, Extractor, K, S> Unpin for Entry<'a, T, Extractor, K, S>
where K: Unpin,

§

impl<'a, T, Extractor, K, S = BuildHasherDefault<AHasher>> !UnwindSafe for Entry<'a, T, Extractor, K, S>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.