pub struct Memo<T>where
T: 'static,{ /* private fields */ }Expand description
Cached, equality-diffed derived value (§4.2).
Implementations§
Source§impl<T> Memo<T>where
T: 'static,
impl<T> Memo<T>where
T: 'static,
pub fn new(f: impl Fn() -> T + 'static) -> Memo<T>where
T: PartialEq,
pub fn new_with_eq( f: impl Fn() -> T + 'static, eq: fn(&T, &T) -> bool, ) -> Memo<T>
Sourcepub fn with<R>(self, f: impl FnOnce(&T) -> R) -> R
pub fn with<R>(self, f: impl FnOnce(&T) -> R) -> R
Tracked read by reference, recomputing first when a source changed.
§Panics
Panics when the memo’s scope was disposed.
pub fn get(self) -> Twhere
T: Clone,
Trait Implementations§
Auto Trait Implementations§
impl<T> !Send for Memo<T>
impl<T> !Sync for Memo<T>
impl<T> Forget for Memo<T>
impl<T> Freeze for Memo<T>
impl<T> Move for Memo<T>
impl<T> RefUnwindSafe for Memo<T>
impl<T> Unpin for Memo<T>
impl<T> UnsafeUnpin for Memo<T>
impl<T> UnwindSafe for Memo<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more