pub struct VecCache<'f, O> { /* private fields */ }Expand description
A cache for a function which uses a Vec.
This cache is optimized for functions which must
be calculated in order, so that there can be no
gaps in the cache, and use usize as an argument.
If the function does not start at zero, or require
every previous value to be calculated for the next
one, consider using a HashCache
instead.
Implementations§
source§impl<'f, O> VecCache<'f, O>
impl<'f, O> VecCache<'f, O>
sourcepub fn new<F>(f: F) -> Selfwhere
F: Fn(&usize) -> O + 'f + Send + Sync,
pub fn new<F>(f: F) -> Selfwhere
F: Fn(&usize) -> O + 'f + Send + Sync,
Create a cache for the provided function. If the function stores references, the cache can only live as long as those references.
sourcepub fn recursive<F>(f: F) -> Selfwhere
F: Fn(&mut Self, &usize) -> O + 'f + Send + Sync,
pub fn recursive<F>(f: F) -> Selfwhere
F: Fn(&mut Self, &usize) -> O + 'f + Send + Sync,
Create a cache for the provided recursive function. If the function stores references, the cache can only live as long as those references.