pub struct TakeCell<T> { /* private fields */ }
Expand description
Inverse of a OnceCell
. It initializes with a value, which then can be raced by other threads to take.
Once the value is taken, it can never be taken again.
Implementations§
Source§impl<T> TakeCell<T>
impl<T> TakeCell<T>
Sourcepub fn try_take(&self) -> Option<T>
pub fn try_take(&self) -> Option<T>
Attempts to take the value from the cell, returning None
if the value has already been taken
Sourcepub fn try_take_mut(&mut self) -> Option<T>
pub fn try_take_mut(&mut self) -> Option<T>
Attempts to take the value from the cell through non-atomic operations, returning None
if the value has already been taken
§Safety
This method is safe because the mutable reference indicates we are the only thread with access to the cell, so atomic operations aren’t required.
Trait Implementations§
impl<T: Send> Send for TakeCell<T>
impl<T: Sync> Sync for TakeCell<T>
Auto Trait Implementations§
impl<T> !Freeze for TakeCell<T>
impl<T> !RefUnwindSafe for TakeCell<T>
impl<T> Unpin for TakeCell<T>where
T: Unpin,
impl<T> UnwindSafe for TakeCell<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