Struct ilyvion_util::cache::Cache
source · [−]pub struct Cache<F, V> where
F: FnOnce() -> V, { /* private fields */ }
Expand description
Caches the result of an (presumably) expensive operation such that accessing the result multiple times doesn’t result in running the expensive operation multiple times.
Implementations
sourceimpl<F, V> Cache<F, V> where
F: FnOnce() -> V,
impl<F, V> Cache<F, V> where
F: FnOnce() -> V,
sourcepub fn new(calculation_fn: F) -> Self
pub fn new(calculation_fn: F) -> Self
Creates a new Cache<F, V>
initialized with the given calculation_fn
function.
The function will not be called until the result of the calculation is needed.
Trait Implementations
Auto Trait Implementations
impl<F, V> RefUnwindSafe for Cache<F, V> where
F: RefUnwindSafe,
V: RefUnwindSafe,
impl<F, V> Send for Cache<F, V> where
F: Send,
V: Send,
impl<F, V> Sync for Cache<F, V> where
F: Sync,
V: Sync,
impl<F, V> Unpin for Cache<F, V> where
F: Unpin,
V: Unpin,
impl<F, V> UnwindSafe for Cache<F, V> where
F: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more