Struct OccupiedEntry
pub struct OccupiedEntry<'a, T, A = Global>
where
A: Allocator, { /* private fields */ }
A view into an occupied entry in a HashTable.
It is part of the Entry enum.
Examples
#
#
#
Implementations
impl<'a, T, A> OccupiedEntry<'a, T, A>
where
A: Allocator,
fn remove(self) -> (T, VacantEntry<'a, T, A>)Takes the value out of the entry, and returns it along with a
VacantEntrythat can be used to insert another value with the same hash as the one that was just removed.Examples
# # #fn get(&self) -> &TGets a reference to the value in the entry.
Examples
# # #fn get_mut(&mut self) -> &mut TGets a mutable reference to the value in the entry.
If you need a reference to the
OccupiedEntrywhich may outlive the destruction of theEntryvalue, seeinto_mut.Examples
# # #fn into_mut(self) -> &'a mut TConverts the
OccupiedEntryinto a mutable reference to the value in the entry with a lifetime bound to the table itself.If you need multiple references to the
OccupiedEntry, seeget_mut.Examples
# # #fn into_table(self) -> &'a mut HashTable<T, A>Converts the
OccupiedEntryinto a mutable reference to the underlying table.fn bucket_index(&self) -> usizeReturns the bucket index in the table for this entry.
This can be used to store a borrow-free "reference" to the entry, later using
HashTable::get_bucket,HashTable::get_bucket_mut, orHashTable::get_bucket_entryto access it again without hash probing.The index is only meaningful as long as the table is not resized and no entries are added or removed. After such changes, it may end up pointing to a different entry or none at all.
Examples
# # #fn replace_entry_with<F>(self, f: F) -> Entry<'a, T, A> where F: FnOnce(T) -> Option<T>,Provides owned access to the value of the entry and allows to replace or remove it based on the value of the returned option.
The hash of the new item should be the same as the old item.
Examples
# # #
Trait Implementations
impl<T, A> Send for OccupiedEntry<'_, T, A>
where
T: Send,
A: Send + Allocator,
impl<T, A> Sync for OccupiedEntry<'_, T, A>
where
T: Sync,
A: Sync + Allocator,
impl<T: Debug, A: Allocator> Debug for OccupiedEntry<'_, T, A>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<'a, T, A = Global> !UnwindSafe for OccupiedEntry<'a, T, A>
impl<'a, T, A> Freeze for OccupiedEntry<'a, T, A>
where
Bucket<T>: Freeze,
&'a mut HashTable<T, A>: Freeze,
impl<'a, T, A> RefUnwindSafe for OccupiedEntry<'a, T, A>
where
Bucket<T>: RefUnwindSafe,
&'a mut HashTable<T, A>: RefUnwindSafe,
impl<'a, T, A> Unpin for OccupiedEntry<'a, T, A>
where
Bucket<T>: Unpin,
&'a mut HashTable<T, A>: Unpin,
impl<'a, T, A> UnsafeUnpin for OccupiedEntry<'a, T, A>
where
Bucket<T>: UnsafeUnpin,
&'a mut HashTable<T, A>: UnsafeUnpin,
Blanket Implementations
impl<T> Any for OccupiedEntry<'a, T, A>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for OccupiedEntry<'a, T, A>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for OccupiedEntry<'a, T, A>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for OccupiedEntry<'a, T, A>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for OccupiedEntry<'a, T, A>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for OccupiedEntry<'a, T, A>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for OccupiedEntry<'a, T, A>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>