[][src]Struct fn_cache::VecCache

pub struct VecCache<'a, O> { /* fields omitted */ }

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]

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

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

Auto Trait Implementations

impl<'a, O> !Send for VecCache<'a, O>

impl<'a, O> Unpin for VecCache<'a, O> where
    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]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]