pub enum InsertOrGetResult<'a, K, V> {
Inserted(&'a mut V),
Existed(&'a mut V, K, V),
}
Expand description
The result of LRUCache::insert_or_get
.
If inserted, it returns a reference to the newly inserted value. If the key already existed, it returns a reference to the existing value, the key and the value.
Variants§
Inserted(&'a mut V)
Element was inserted, key and value were consumed.
Existed(&'a mut V, K, V)
Element already existed at the given key, so a reference to the existing value is returned, along with the given key and value.
Implementations§
Source§impl<'a, K, V> InsertOrGetResult<'a, K, V>
impl<'a, K, V> InsertOrGetResult<'a, K, V>
Sourcepub fn into_inner(self) -> &'a mut V
pub fn into_inner(self) -> &'a mut V
Consumes the result and returns a reference to the value.
This will drop the key and value if they existed.
Trait Implementations§
Source§impl<K, V> Deref for InsertOrGetResult<'_, K, V>
impl<K, V> Deref for InsertOrGetResult<'_, K, V>
Source§impl<K, V> DerefMut for InsertOrGetResult<'_, K, V>
impl<K, V> DerefMut for InsertOrGetResult<'_, K, V>
impl<'a, K: Eq, V: Eq> Eq for InsertOrGetResult<'a, K, V>
impl<'a, K, V> StructuralPartialEq for InsertOrGetResult<'a, K, V>
Auto Trait Implementations§
impl<'a, K, V> Freeze for InsertOrGetResult<'a, K, V>
impl<'a, K, V> RefUnwindSafe for InsertOrGetResult<'a, K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<'a, K, V> Send for InsertOrGetResult<'a, K, V>
impl<'a, K, V> Sync for InsertOrGetResult<'a, K, V>
impl<'a, K, V> Unpin for InsertOrGetResult<'a, K, V>
impl<'a, K, V> !UnwindSafe for InsertOrGetResult<'a, K, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more