intrusive_lru_cache

Struct SmartEntry

Source
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>

Source

pub fn key(&self) -> &K

Access the key only, without updating the LRU order.

Source

pub fn peek(&self) -> (&K, &V)

Access the key-value pair immutably, without updating the LRU order.

Source

pub fn peek_value(&self) -> &V

Access the value immutably, without updating the LRU order.

This is the same as SmartEntry::deref.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<K, V> Deref for SmartEntry<'_, K, V>

Source§

fn deref(&self) -> &Self::Target

Dereferences the value, without updating the LRU order.

Source§

type Target = V

The resulting type after dereferencing.
Source§

impl<K, V> DerefMut for SmartEntry<'_, K, V>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value, and updates the LRU order.

Auto Trait Implementations§

§

impl<'a, K, V> Freeze for SmartEntry<'a, K, V>

§

impl<'a, K, V> !RefUnwindSafe for SmartEntry<'a, K, V>

§

impl<'a, K, V> !Send for SmartEntry<'a, K, V>

§

impl<'a, K, V> !Sync for SmartEntry<'a, K, V>

§

impl<'a, K, V> Unpin for SmartEntry<'a, K, V>

§

impl<'a, K, V> !UnwindSafe for SmartEntry<'a, K, V>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.