pub enum Entry<Occ, Vac> {
    Occupied(Occ),
    Vacant(Vac),
}
Expand description

An entry which is either Occupied or Vacant.

This is for manipulating key-value map collections, for example HashMap, BTreeMap (also the Set variants, but those just have V set to ()).

Variants

Occupied(Occ)

Vacant(Vac)

Implementations

get a reference to the key this entry corresponds to.

get a reference to the key and value of this entry, if it’s occupied.

if it’s not occupied, get a reference to the vacant key.

get an immutable reference to the key and a mutable reference to the value of this entry, if it’s occupied.

if it’s not occupied, get a reference to the vacant key.

consume this entry and return a mutable reference to the value in the collection,

if it’s not occupied, get a vacant entry.

source

pub fn insert_into_entry(self, value: Occ::Value) -> (Self, Option<Occ::Value>)

try to insert into the entry, returning a new entry, and a value if it was occupied.

set the value, returning the OccupiedEntry, and the displaced value if there was one.

returns true if the entry is occupied.

returns true if the entry is vacant.

source

pub fn remove_entry(self) -> (Self, Option<Occ::Value>)

remove this entry, returning a new entry. for keyed collections this will be vacant.

remove this entry, returning the newly vacated entry, and the value if it was occupied.

remove the entry, and return an owned key, and an optional value, if it was occupied.

insert a new entry in this place. if the entry is vacant, it will be filled. if it is not vacant, it will be inserted here.

Trait Implementations

Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.