[−][src]Struct fn_cache::VecCache
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.
Methods
impl<'a, O> VecCache<'a, O>
[src]
pub fn new<F>(f: F) -> Self where
F: Fn(&mut Self, &usize) -> O + 'a,
[src]
F: Fn(&mut Self, &usize) -> O + 'a,
Create a cache for the provided function. If the function stores references, the cache can only live as long as those references.
pub fn clear(&mut self)
[src]
Clears the cache. removing all values. Keeps the allocated memory for reuse.
pub fn len(&self) -> usize
[src]
Returns the number of elements in the cache.
pub fn reserve(&mut self, additional: usize)
[src]
Reserves capacity for at least additional
more elements
to be inserted in the cache. The collection may
reserve more space to avoid frequent reallocations.
Trait Implementations
Auto Trait Implementations
impl<'a, O> !Send for VecCache<'a, O>
impl<'a, O> Unpin for VecCache<'a, O> where
O: Unpin,
O: Unpin,
impl<'a, O> !Sync for VecCache<'a, O>
impl<'a, O> !UnwindSafe for VecCache<'a, O>
impl<'a, O> !RefUnwindSafe for VecCache<'a, O>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,