Struct MappedMutexGuard

struct MappedMutexGuard<'a, T: ?Sized, U: ?Sized> { ... }

An RAII guard returned by the MutexGuard::map and MappedMutexGuard::map methods. When this structure is dropped (falls out of scope), the lock will be unlocked.

Implementations

impl<'a, T: ?Sized, U: ?Sized> MappedMutexGuard<'a, T, U>

fn map<V: ?Sized, F>(this: Self, f: F) -> MappedMutexGuard<'a, T, V>
where
    F: FnOnce(&mut U) -> &mut V

Returns a locked view over a portion of the locked data.

Example

# futures::executor::block_on(async {
use futures::lock::{MappedMutexGuard, Mutex, MutexGuard};

let data = Mutex::new(Some("value".to_string()));
{
    let locked_str = MutexGuard::map(data.lock().await, |opt| opt.as_mut().unwrap());
    let locked_char = MappedMutexGuard::map(locked_str, |s| s.get_mut(0..1).unwrap());
    assert_eq!(&*locked_char, "v");
}
# });

impl<'a, T, U> Freeze for MappedMutexGuard<'a, T, U>

impl<'a, T, U> RefUnwindSafe for MappedMutexGuard<'a, T, U>

impl<'a, T, U> Unpin for MappedMutexGuard<'a, T, U>

impl<'a, T, U> UnsafeUnpin for MappedMutexGuard<'a, T, U>

impl<'a, T, U> UnwindSafe for MappedMutexGuard<'a, T, U>

impl<P, T> Receiver for MappedMutexGuard<'a, T, U>

impl<T> Any for MappedMutexGuard<'a, T, U>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for MappedMutexGuard<'a, T, U>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for MappedMutexGuard<'a, T, U>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for MappedMutexGuard<'a, T, U>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for MappedMutexGuard<'a, T, U>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for MappedMutexGuard<'a, T, U>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for MappedMutexGuard<'a, T, U>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>

impl<T: ?Sized + Send, U: ?Sized + Send> Send for MappedMutexGuard<'_, T, U>

impl<T: ?Sized + Sync, U: ?Sized + Sync> Sync for MappedMutexGuard<'_, T, U>

impl<T: ?Sized, U: ?Sized + fmt::Debug> Debug for MappedMutexGuard<'_, T, U>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<T: ?Sized, U: ?Sized> Deref for MappedMutexGuard<'_, T, U>

fn deref(self: &Self) -> &U

impl<T: ?Sized, U: ?Sized> DerefMut for MappedMutexGuard<'_, T, U>

fn deref_mut(self: &mut Self) -> &mut U

impl<T: ?Sized, U: ?Sized> Drop for MappedMutexGuard<'_, T, U>

fn drop(self: &mut Self)