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