Trait FnMemo

Source
pub trait FnMemo<Arg, Output> {
    // Required methods
    fn call(&self, arg: Arg) -> Output;
    fn clear_cache(&self);
}
Expand description

The memoized function.

Required Methods§

Source

fn call(&self, arg: Arg) -> Output

Calls the function. If the result of arg is already cached, it will return the cached result, otherwise, it calculates the result and adds it to the cache.

Source

fn clear_cache(&self)

Clears the cache.

Implementors§

Source§

impl<C: Cache, F: RecurFn<C::Arg, C::Output>> FnMemo<<C as Cache>::Arg, <C as Cache>::Output> for fn_memo::sync::Memo<C, F>
where C::Arg: Clone, C::Output: Clone,

Source§

impl<C: Cache, F: RecurFn<C::Arg, C::Output>> FnMemo<<C as Cache>::Arg, <C as Cache>::Output> for fn_memo::unsync::Memo<C, F>
where C::Arg: Clone, C::Output: Clone,