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
sourceimpl<Occ, Vac> Entry<Occ, Vac>
impl<Occ, Vac> Entry<Occ, Vac>
pub fn from_occupied(entry: Occ) -> Self
pub fn from_vacant(entry: Vac) -> Self
sourceimpl<'c, 'e, Occ, Vac> Entry<Occ, Vac> where
'c: 'e,
Occ: KeyedOccupiedEntry<'c>,
Vac: KeyedVacantEntry<'c, Value = Occ::Value, Occupied = Occ, Key = Occ::Key>,
impl<'c, 'e, Occ, Vac> Entry<Occ, Vac> where
'c: 'e,
Occ: KeyedOccupiedEntry<'c>,
Vac: KeyedVacantEntry<'c, Value = Occ::Value, Occupied = Occ, Key = Occ::Key>,
sourceimpl<'c, 'e, Occ, Vac> Entry<Occ, Vac> where
'c: 'e,
Occ: KeyedOccupiedEntry<'c>,
Vac: KeyedVacantEntry<'c, Value = Occ::Value, Occupied = Occ>,
impl<'c, 'e, Occ, Vac> Entry<Occ, Vac> where
'c: 'e,
Occ: KeyedOccupiedEntry<'c>,
Vac: KeyedVacantEntry<'c, Value = Occ::Value, Occupied = Occ>,
sourcepub fn get_pair(
&'e self
) -> Result<(&'e Occ::Key, &'e Occ::Value), &'e Vac::Key>
pub fn get_pair(
&'e self
) -> Result<(&'e Occ::Key, &'e Occ::Value), &'e Vac::Key>
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.
sourcepub fn get_pair_mut(
&'e mut self
) -> Result<(&'e Occ::Key, &'e mut Occ::Value), &'e Vac::Key>
pub fn get_pair_mut(
&'e mut self
) -> Result<(&'e Occ::Key, &'e mut Occ::Value), &'e Vac::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.
sourcepub fn into_pair(self) -> Result<(Occ::BorrowedKey, &'c mut Occ::Value), Vac>
pub fn into_pair(self) -> Result<(Occ::BorrowedKey, &'c mut Occ::Value), Vac>
consume this entry and return a mutable reference to the value in the collection,
if it’s not occupied, get a vacant entry.
sourcepub fn insert_into_entry(self, value: Occ::Value) -> (Self, Option<Occ::Value>)
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.
sourcepub fn occupy(self, value: Occ::Value) -> (Occ, Option<Occ::Value>)
pub fn occupy(self, value: Occ::Value) -> (Occ, Option<Occ::Value>)
set the value, returning the OccupiedEntry, and the displaced value if there was one.
sourcepub fn is_occupied(&'e self) -> bool
pub fn is_occupied(&'e self) -> bool
returns true if the entry is occupied.
sourceimpl<'c, Occ, Vac> Entry<Occ, Vac> where
Occ: EntryRemovableOccupiedEntry<'c, Vacant = Vac>,
impl<'c, Occ, Vac> Entry<Occ, Vac> where
Occ: EntryRemovableOccupiedEntry<'c, Vacant = Vac>,
sourceimpl<'c, Occ, Vac> Entry<Occ, Vac> where
Occ: RemovableOccupiedEntry<'c, Removed = Vac>,
impl<'c, Occ, Vac> Entry<Occ, Vac> where
Occ: RemovableOccupiedEntry<'c, Removed = Vac>,
sourceimpl<'c, Occ, Vac> Entry<Occ, Vac> where
Occ: RemovableOccupiedEntry<'c, Removed = Vac>,
Occ: KeyedOccupiedEntry<'c>,
Vac: KeyedVacantEntry<'c, Key = Occ::Key, Occupied = Occ>,
impl<'c, Occ, Vac> Entry<Occ, Vac> where
Occ: RemovableOccupiedEntry<'c, Removed = Vac>,
Occ: KeyedOccupiedEntry<'c>,
Vac: KeyedVacantEntry<'c, Key = Occ::Key, Occupied = Occ>,
sourceimpl<'c, Occ, Vac> Entry<Occ, Vac> where
Occ: InsertableOccupiedEntry<'c>,
Vac: VacantEntry<'c, Occupied = Occ, Value = Occ::Value>,
impl<'c, Occ, Vac> Entry<Occ, Vac> where
Occ: InsertableOccupiedEntry<'c>,
Vac: VacantEntry<'c, Occupied = Occ, Value = Occ::Value>,
sourcepub fn insert_new(self, value: Occ::Value)
pub fn insert_new(self, value: Occ::Value)
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.
pub fn occupy_new(self, value: Occ::Value) -> Occ
sourceimpl<'c, Occ, Vac> Entry<Occ, Vac> where
Occ: NextOccupiedFromOccupied<'c>,
Occ::Key: Ord,
Vac: NextOccupiedFromVacant<'c, Occupied = Occ>,
impl<'c, Occ, Vac> Entry<Occ, Vac> where
Occ: NextOccupiedFromOccupied<'c>,
Occ::Key: Ord,
Vac: NextOccupiedFromVacant<'c, Occupied = Occ>,
pub fn get_next_occupied(self) -> Option<Occ>
sourceimpl<'c, Occ, Vac> Entry<Occ, Vac> where
Occ: PrevOccupiedFromOccupied<'c>,
Occ::Key: Ord,
Vac: PrevOccupiedFromVacant<'c, Occupied = Occ>,
impl<'c, Occ, Vac> Entry<Occ, Vac> where
Occ: PrevOccupiedFromOccupied<'c>,
Occ::Key: Ord,
Vac: PrevOccupiedFromVacant<'c, Occupied = Occ>,
pub fn get_prev_occupied(self) -> Option<Occ>
Trait Implementations
sourceimpl<'c, Occ, Vac, K> From<EntryWithSearchKey<Occ, Vac, K>> for Entry<Occ, Vac>
impl<'c, Occ, Vac, K> From<EntryWithSearchKey<Occ, Vac, K>> for Entry<Occ, Vac>
sourcefn from(entry: EntryWithSearchKey<Occ, Vac, K>) -> Self
fn from(entry: EntryWithSearchKey<Occ, Vac, K>) -> Self
Converts to this type from the input type.
sourceimpl<'c, Occ, Vec> IntoCollectionMut<'c> for Entry<Occ, Vec> where
Occ: IntoCollectionMut<'c>,
Vec: IntoCollectionMut<'c, Collection = Occ::Collection>,
impl<'c, Occ, Vec> IntoCollectionMut<'c> for Entry<Occ, Vec> where
Occ: IntoCollectionMut<'c>,
Vec: IntoCollectionMut<'c, Collection = Occ::Collection>,
type Collection = Occ::Collection
fn into_collection_mut(self) -> &'c mut Self::Collection
Auto Trait Implementations
impl<Occ, Vac> RefUnwindSafe for Entry<Occ, Vac> where
Occ: RefUnwindSafe,
Vac: RefUnwindSafe,
impl<Occ, Vac> Send for Entry<Occ, Vac> where
Occ: Send,
Vac: Send,
impl<Occ, Vac> Sync for Entry<Occ, Vac> where
Occ: Sync,
Vac: Sync,
impl<Occ, Vac> Unpin for Entry<Occ, Vac> where
Occ: Unpin,
Vac: Unpin,
impl<Occ, Vac> UnwindSafe for Entry<Occ, Vac> where
Occ: UnwindSafe,
Vac: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more