Struct MappedMutexGuard
struct MappedMutexGuard<'a, T: ?Sized + 'a> { ... }
An RAII mutex guard returned by MutexGuard::map, which can point to a
subfield of the protected data. When this structure is dropped (falls out
of scope), the lock will be unlocked.
The main difference between MappedMutexGuard and MutexGuard is that the
former cannot be used with Condvar, since that could introduce soundness issues if the
locked object is modified by another thread while the Mutex is 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 map and filter_map methods on
MutexGuard.
Implementations
impl<'a, T: ?Sized> MappedMutexGuard<'a, T>
fn map<U, F>(orig: Self, f: F) -> MappedMutexGuard<'a, U> where F: FnOnce(&mut T) -> &mut U, U: ?SizedMakes a
MappedMutexGuardfor a component of the borrowed data, e.g. an enum variant.The
Mutexis already locked, so this cannot fail.This is an associated function that needs to be used as
MappedMutexGuard::map(...). A method would interfere with methods of the same name on the contents of theMutexGuardused throughDeref.fn filter_map<U, F>(orig: Self, f: F) -> Result<MappedMutexGuard<'a, U>, Self> where F: FnOnce(&mut T) -> Option<&mut U>, U: ?SizedMakes a
MappedMutexGuardfor a component of the borrowed data. The original guard is returned as anErr(...)if the closure returnsNone.The
Mutexis already locked, so this cannot fail.This is an associated function that needs to be used as
MappedMutexGuard::filter_map(...). A method would interfere with methods of the same name on the contents of theMutexGuardused throughDeref.
impl<'a, T> Freeze for MappedMutexGuard<'a, T>
impl<'a, T> RefUnwindSafe for MappedMutexGuard<'a, T>
impl<'a, T> Unpin for MappedMutexGuard<'a, T>
impl<'a, T> UnsafeUnpin for MappedMutexGuard<'a, T>
impl<'a, T> UnwindSafe for MappedMutexGuard<'a, T>
impl<P, T> Receiver for MappedMutexGuard<'a, T>
impl<T> Any for MappedMutexGuard<'a, T>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for MappedMutexGuard<'a, T>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for MappedMutexGuard<'a, T>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for MappedMutexGuard<'a, T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToString for MappedMutexGuard<'a, T>
fn to_string(self: &Self) -> String
impl<T, U> Into for MappedMutexGuard<'a, T>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for MappedMutexGuard<'a, T>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for MappedMutexGuard<'a, T>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T: ?Sized + Sync> Sync for MappedMutexGuard<'_, T>
impl<T: ?Sized + fmt::Debug> Debug for MappedMutexGuard<'_, T>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<T: ?Sized + fmt::Display> Display for MappedMutexGuard<'_, T>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<T: ?Sized> Deref for MappedMutexGuard<'_, T>
fn deref(self: &Self) -> &T
impl<T: ?Sized> DerefMut for MappedMutexGuard<'_, T>
fn deref_mut(self: &mut Self) -> &mut T
impl<T: ?Sized> Drop for MappedMutexGuard<'_, T>
fn drop(self: &mut Self)