[][src]Trait fn_cache::FnCache

pub trait FnCache<I, O> {
    fn get(&mut self, input: I) -> &O;
}

The generic trait for all caches.

This trait is implemented on all caches. This allows someone to write a function like fn f(cache: &mut impl FnCache<u32,u32>, x: &u32) -> u32 and have it work for all the caches written in this crate.

Required methods

fn get(&mut self, input: I) -> &O

Retrieve a value stored in the cache. If the value does not yet exist in the cache, the function is called, and the result is added to the cache before returning it.

Loading content...

Implementors

impl<'a, I, O, S> FnCache<I, O> for HashCache<'a, I, O, S> where
    I: Eq + Hash,
    S: BuildHasher
[src]

impl<'a, I, O, V> FnCache<I, V> for BTreeCache<'a, I, O, V> where
    I: Ord,
    O: Into<V>, 
[src]

impl<'a, O> FnCache<usize, O> for VecCache<'a, O>[src]

Loading content...