Trait FnCacheMany

Source
pub trait FnCacheMany<I, O>: FnCache<I, O> {
    // Required method
    fn get_many<const N: usize>(&mut self, inputs: [I; N]) -> [&O; N];
}
Expand description

The generic trait for caches which support getting multiple values.

This trait may have additional restrictions such as I is Clone. This allows someone to write a function like fn f(cache: &mut impl FnCacheMany<u32,u32>, x: &u32) -> u32 and have it work in most cases when the key is cloneable with caches in this crate.

Required Methods§

Source

fn get_many<const N: usize>(&mut self, inputs: [I; N]) -> [&O; N]

Retrieve multiple values stored in the cache. If any of the values do not yet exist, the function is called, and the result is added to the cache before returning them.

This is helpful for cases which may require a recursive definition that uses multiple values at once.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'c, C> FnCacheMany<<C as SparseContainer>::Input, <C as SparseContainer>::Output> for RefCache<'c, C>
where C: SparseContainer, C::Input: Clone,

Source§

impl<'f, C> FnCacheMany<<C as SparseContainer>::Input, <C as SparseContainer>::Output> for GenericCache<'f, C>
where C: SparseContainer, C::Input: Clone,

Source§

impl<'f, O> FnCacheMany<usize, O> for VecCache<'f, O>