pub struct KeyedCache<F, K, V> where
    F: FnMut(&K) -> V,
    K: Hash + Eq
{ /* private fields */ }
Expand description

Caches the result of an (presumably) expensive operation such that accessing the result multiple times doesn’t result in running the expensive operation multiple times.

Implementations

Creates a new KeyedCache<F, V> initialized with the given calculation_fn function. The function will not be called until the result of a calculation is needed.

Gets a mutable reference to a contained calculated value based on the key. Runs the calculation function if this method call is the first time the value with the given key is accessed.

Gets a shared reference to the contained calculated value based on the key if it has already been calculated.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Takes a closure and calls it with Self, then returns whatever the closure returned. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.