Struct ilyvion_util::cache::KeyedCache
source · pub struct KeyedCache<F, K, V>where
F: FnMut(&K) -> V,
K: Hash + Eq,{ /* 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§
source§impl<F, K, V> KeyedCache<F, K, V>where
F: FnMut(&K) -> V,
K: Hash + Eq,
impl<F, K, V> KeyedCache<F, K, V>where F: FnMut(&K) -> V, K: Hash + Eq,
sourcepub fn new(calculation_fn: F) -> Self
pub fn new(calculation_fn: F) -> Self
Creates a new KeyedCache<F, V>
initialized with the given calculation_fn
function.
The function will not be called until the result of a calculation is needed.
Trait Implementations§
Auto Trait Implementations§
impl<F, K, V> RefUnwindSafe for KeyedCache<F, K, V>where F: RefUnwindSafe, K: RefUnwindSafe, V: RefUnwindSafe,
impl<F, K, V> Send for KeyedCache<F, K, V>where F: Send, K: Send, V: Send,
impl<F, K, V> Sync for KeyedCache<F, K, V>where F: Sync, K: Sync, V: Sync,
impl<F, K, V> Unpin for KeyedCache<F, K, V>where F: Unpin, K: Unpin, V: Unpin,
impl<F, K, V> UnwindSafe for KeyedCache<F, K, V>where F: UnwindSafe, K: UnwindSafe, V: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more