pub struct MappedMutexGuard<'a, T: ?Sized + 'a> { /* private fields */ }
mapped_lock_guards #117108)
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.
impl<'a, T: ?Sized> MappedMutexGuard<'a, T>
pub fn map<U, F>(orig: Self, f: F) -> MappedMutexGuard<'a, U>where
F: FnOnce(&mut T) -> &mut U,
U: ?Sized,mapped_lock_guards #117108)
Makes a MappedMutexGuard for a component of the borrowed data, e.g. an enum variant.
The Mutex is 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 the MutexGuard used through Deref.
pub fn filter_map<U, F>(
orig: Self,
f: F,
) -> Result<MappedMutexGuard<'a, U>, Self>where
F: FnOnce(&mut T) -> Option<&mut U>,
U: ?Sized,mapped_lock_guards #117108)
Makes a MappedMutexGuard for a component of the borrowed data. The original guard is returned as an Err(...) if the closure returns None.
The Mutex is 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 the MutexGuard used through Deref.
impl<T: ?Sized + Debug> Debug for MappedMutexGuard<'_, T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T: ?Sized> Deref for MappedMutexGuard<'_, T>
type Target = T
fn deref(&self) -> &T
impl<T: ?Sized> DerefMut for MappedMutexGuard<'_, T>
fn deref_mut(&mut self) -> &mut T
impl<T: ?Sized + Display> Display for MappedMutexGuard<'_, T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T: ?Sized> Drop for MappedMutexGuard<'_, T>
impl<T: ?Sized> !Send for MappedMutexGuard<'_, T>
impl<T: ?Sized + Sync> Sync for MappedMutexGuard<'_, T>
impl<'a, T> Freeze for MappedMutexGuard<'a, T>where
T: ?Sized,impl<'a, T> RefUnwindSafe for MappedMutexGuard<'a, T>where
T: RefUnwindSafe + ?Sized,impl<'a, T> Unpin for MappedMutexGuard<'a, T>where
T: ?Sized,impl<'a, T> !UnwindSafe for MappedMutexGuard<'a, T>
impl<T> Any for Twhere
T: 'static + ?Sized,impl<T> Borrow<T> for Twhere
T: ?Sized,impl<T> BorrowMut<T> for Twhere
T: ?Sized,impl<T> From<T> for T
fn from(t: T) -> T
Returns the argument unchanged.
impl<T, U> Into<U> for Twhere
U: From<T>,fn into(self) -> U
Calls U::from(self).
That is, this conversion is whatever the implementation of From<T> for U chooses to do.
impl<P, T> Receiver for Pwhere
P: Deref<Target = T> + ?Sized,
T: ?Sized,type Target = T
arbitrary_self_types #44874)
impl<T> ToString for Twhere
T: Display + ?Sized,impl<T, U> TryFrom<U> for Twhere
U: Into<T>,type Error = Infallible
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/sync/nonpoison/struct.MappedMutexGuard.html