pub struct MutexGuard<'a, T: ?Sized>(/* private fields */);Expand description
Provides exclusive access to an object controlled by a Mutex via the
RAII pattern.
§Behaviour
This object represents the current task’s ownership of the mutex. As such,
it explicitly does not implement the Send trait—meaning that this
ownership cannot be transferred to another task—and its destructor, via
the Drop trait, ensures that the mutex is released when the object goes
out of scope. Rust’s object and reference lifetime rules prevent safe code
from retaining access to the Mutex object’s internal data beyond the
lifetime of the guard object.
Trait Implementations§
Source§impl<T: ?Sized> Deref for MutexGuard<'_, T>
impl<T: ?Sized> Deref for MutexGuard<'_, T>
Source§impl<T: ?Sized> DerefMut for MutexGuard<'_, T>
impl<T: ?Sized> DerefMut for MutexGuard<'_, T>
Source§impl<T: ?Sized> Drop for MutexGuard<'_, T>
impl<T: ?Sized> Drop for MutexGuard<'_, T>
impl<T: ?Sized> !Send for MutexGuard<'_, T>
impl<T: ?Sized + Sync> Sync for MutexGuard<'_, T>
Auto Trait Implementations§
impl<'a, T> Freeze for MutexGuard<'a, T>where
T: ?Sized,
impl<'a, T> !RefUnwindSafe for MutexGuard<'a, T>
impl<'a, T> Unpin for MutexGuard<'a, T>where
T: ?Sized,
impl<'a, T> !UnwindSafe for MutexGuard<'a, T>
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