pub enum Cached<T: Clone + Debug> {
Empty,
Unused(T),
Used(T),
}
Expand description
Helper for caching a value when the value is optionally present in the ‘unused’ state.
Variants§
Implementations§
source§impl<T: Clone + Debug> Cached<T>
impl<T: Clone + Debug> Cached<T>
sourcepub fn take_unused(&mut self) -> Option<T>
pub fn take_unused(&mut self) -> Option<T>
Takes the buffered value if in state Self::Unused
.
sourcepub fn set_unused(&mut self)
pub fn set_unused(&mut self)
Moves the value from Self::Used
to Self::Unused
.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Cached<T>where
T: Freeze,
impl<T> RefUnwindSafe for Cached<T>where
T: RefUnwindSafe,
impl<T> Send for Cached<T>where
T: Send,
impl<T> Sync for Cached<T>where
T: Sync,
impl<T> Unpin for Cached<T>where
T: Unpin,
impl<T> UnwindSafe for Cached<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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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