pub struct MutexCell<T> { /* private fields */ }
Implementations§
Source§impl<T> MutexCell<T>
impl<T> MutexCell<T>
Sourcepub fn new(data: T) -> MutexCell<T>
pub fn new(data: T) -> MutexCell<T>
Create a new MutexCell with a value.
§Example
use with_lock::MutexCell;
let mutex = MutexCell::new(23);
assert_eq!(mutex.get(), 23)
Sourcepub fn get_mut(&mut self) -> &mut Twhere
T: Copy,
pub fn get_mut(&mut self) -> &mut Twhere
T: Copy,
Returns a mutable reference to the underlying data.
Sourcepub fn replace(&self, val: T) -> T
pub fn replace(&self, val: T) -> T
Replaces the contained value with val
, and returns the old contained value.
Sourcepub fn take(&self) -> Twhere
T: Default,
pub fn take(&self) -> Twhere
T: Default,
Takes the value of the cell, leaving Default::default()
in its place.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Unwraps the value.
Auto Trait Implementations§
impl<T> !Freeze for MutexCell<T>
impl<T> !RefUnwindSafe for MutexCell<T>
impl<T> Send for MutexCell<T>where
T: Send,
impl<T> Sync for MutexCell<T>where
T: Send,
impl<T> Unpin for MutexCell<T>where
T: Unpin,
impl<T> UnwindSafe for MutexCell<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