pub struct Mutex<T: ?Sized> { /* private fields */ }Expand description
A mutual exclusive lock
Implementations§
Source§impl<T> Mutex<T>
impl<T> Mutex<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the Mutex, returning the inner value.
Source§impl<T> Mutex<T>where
T: ?Sized,
impl<T> Mutex<T>where
T: ?Sized,
Sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Get a mutable reference of the inner value T. This is safe because we have the mutable reference of the lock.
Sourcepub fn try_lock<'a>(&'a self) -> Option<MutexGuard<'a, T>>
pub fn try_lock<'a>(&'a self) -> Option<MutexGuard<'a, T>>
Try lock the Mutex, returns the mutex guard. Returns None if the
Mutex is write locked.
Sourcepub fn lock<'a>(&'a self) -> MutexGuard<'a, T>
pub fn lock<'a>(&'a self) -> MutexGuard<'a, T>
Lock the Mutex, returns the mutex guard.
§Panics
If the Mutex is already locked, this will panic if the check feature
is turned on.
Trait Implementations§
impl<T> RefUnwindSafe for Mutex<T>where
T: ?Sized,
impl<T> Send for Mutex<T>
impl<T> Sync for Mutex<T>
impl<T> UnwindSafe for Mutex<T>where
T: ?Sized,
Auto Trait Implementations§
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