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 immutably, without updating the LRU order.
Sourcepub fn peek_value(&self) -> &V
pub fn peek_value(&self) -> &V
Access the value immutably, without updating the LRU order.
This is the same as SmartEntry::deref
.
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.
Sourcepub fn get_value(&mut self) -> &mut V
pub fn get_value(&mut self) -> &mut V
Access the value mutably, and update the LRU order.
This 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.