pub struct MutexGuard<'a, T, Lock: RawMutex> { /* private fields */ }Expand description
An RAII implementation of a “scoped lock” of a mutex. When this structure is dropped (falls out of scope), the lock will be unlocked.
The data protected by the mutex can be accessed through this guard via its
Deref and DerefMut implementations.
This structure is created by the lock and try_lock methods on
Mutex.
Trait Implementations§
Source§impl<T, Lock, R: ?Sized> AsMut<R> for MutexGuard<'_, T, Lock>
impl<T, Lock, R: ?Sized> AsMut<R> for MutexGuard<'_, T, Lock>
Source§impl<T, Lock, R: ?Sized> AsRef<R> for MutexGuard<'_, T, Lock>
impl<T, Lock, R: ?Sized> AsRef<R> for MutexGuard<'_, T, Lock>
Source§impl<T, Lock> Debug for MutexGuard<'_, T, Lock>
impl<T, Lock> Debug for MutexGuard<'_, T, Lock>
Source§impl<T, Lock: RawMutex> Deref for MutexGuard<'_, T, Lock>
impl<T, Lock: RawMutex> Deref for MutexGuard<'_, T, Lock>
Source§impl<T, Lock: RawMutex> DerefMut for MutexGuard<'_, T, Lock>
impl<T, Lock: RawMutex> DerefMut for MutexGuard<'_, T, Lock>
Source§impl<T, Lock> Display for MutexGuard<'_, T, Lock>
impl<T, Lock> Display for MutexGuard<'_, T, Lock>
Source§impl<T, Lock> Drop for MutexGuard<'_, T, Lock>where
Lock: RawMutex,
impl<T, Lock> Drop for MutexGuard<'_, T, Lock>where
Lock: RawMutex,
impl<T, Lock> Send for MutexGuard<'_, T, Lock>
A MutexGuard is only Send if:
- the protected data (
T) isSend, because the guard may be used to mutably access the protected data, and can therefore be used to move it usingcore::mem::replaceor similar. - the
Locktype parameter isSync, because the guard contains a reference to theLocktype, and therefore, sending the guard is sharing a reference to theLock. - the
Locktype’sRawMutex::GuardMarkerassociated type isSend, because this indicates that theLocktype agrees that guards may beSend.
Auto Trait Implementations§
impl<'a, T, Lock> Freeze for MutexGuard<'a, T, Lock>
impl<'a, T, Lock> RefUnwindSafe for MutexGuard<'a, T, Lock>
impl<'a, T, Lock> !Sync for MutexGuard<'a, T, Lock>
impl<'a, T, Lock> Unpin for MutexGuard<'a, T, Lock>
impl<'a, T, Lock> UnwindSafe for MutexGuard<'a, T, Lock>
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