pub struct MemoSlot<T: Clone> { /* private fields */ }Expand description
A memoized computation slot that stores a cached value.
Implementations§
Source§impl<T: Clone> MemoSlot<T>
impl<T: Clone> MemoSlot<T>
Sourcepub fn get_or_compute(&mut self, f: impl FnOnce() -> T) -> &T
pub fn get_or_compute(&mut self, f: impl FnOnce() -> T) -> &T
Returns the cached value, computing it with f if absent.
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Invalidates the cached value.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for MemoSlot<T>where
T: Freeze,
impl<T> RefUnwindSafe for MemoSlot<T>where
T: RefUnwindSafe,
impl<T> Send for MemoSlot<T>where
T: Send,
impl<T> Sync for MemoSlot<T>where
T: Sync,
impl<T> Unpin for MemoSlot<T>where
T: Unpin,
impl<T> UnsafeUnpin for MemoSlot<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for MemoSlot<T>where
T: 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