pub enum GetOrInsertResult<'a, K, V> {
Inserted(&'a mut V),
Existed(&'a mut V, K),
}
Expand description
The result of LRUCache::get_or_insert
.
If inserted, it returns a reference to the newly inserted value. If the key already existed, it returns a reference to the existing value, and the provided key.
Variants§
Inserted(&'a mut V)
Element was inserted, key and value were consumed.
Existed(&'a mut V, K)
Element already existed at the given key, so a reference to the existing value is returned, along with the given key.
Implementations§
Source§impl<'a, K, V> GetOrInsertResult<'a, K, V>
impl<'a, K, V> GetOrInsertResult<'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 if it existed.
Trait Implementations§
Source§impl<K, V> Deref for GetOrInsertResult<'_, K, V>
impl<K, V> Deref for GetOrInsertResult<'_, K, V>
Source§impl<K, V> DerefMut for GetOrInsertResult<'_, K, V>
impl<K, V> DerefMut for GetOrInsertResult<'_, K, V>
impl<'a, K: Eq, V: Eq> Eq for GetOrInsertResult<'a, K, V>
impl<'a, K, V> StructuralPartialEq for GetOrInsertResult<'a, K, V>
Auto Trait Implementations§
impl<'a, K, V> Freeze for GetOrInsertResult<'a, K, V>where
K: Freeze,
impl<'a, K, V> RefUnwindSafe for GetOrInsertResult<'a, K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<'a, K, V> Send for GetOrInsertResult<'a, K, V>
impl<'a, K, V> Sync for GetOrInsertResult<'a, K, V>
impl<'a, K, V> Unpin for GetOrInsertResult<'a, K, V>where
K: Unpin,
impl<'a, K, V> !UnwindSafe for GetOrInsertResult<'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