pub struct SmartEntry<'a, K, V> { /* private fields */ }
Expand description
An entry in the cache that can be used for for reading or writing, only updating the LRU order when the value is accessed mutably.
The Deref
and DerefMut
implementations allow for easy access to the value,
without or with updating the LRU order, respectively. Accessing the value mutably
via DerefMut
will update the LRU order.
See SmartEntry::peek
and SmartEntry::get
for more information.
Implementations§
Source§impl<K, V> SmartEntry<'_, K, V>
impl<K, V> SmartEntry<'_, K, V>
Sourcepub fn peek(&self) -> (&K, &V)
pub fn peek(&self) -> (&K, &V)
Access the key-value pair, without updating the LRU order.
The Deref
implementation invokes this method to access the value.
Sourcepub fn get(&mut self) -> (&K, &mut V)
pub fn get(&mut self) -> (&K, &mut V)
Access the key-value pair, and update the LRU order.
The LRU order is updated every time this method is called, as it is assumed that the caller is actively using the value.
The DerefMut
implementation invokes this method to access the value,
updating the LRU order in the process.