Struct MappedMutexGuard

#[must_use = "if unused the Mutex will immediately unlock"]
pub struct MappedMutexGuard<'a, T: ?Sized> { /* private fields */ }

A handle to a held Mutex that has had a function applied to it via MutexGuard::map.

This can be used to hold a subfield of the protected data.

Implementations

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

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

Makes a new MappedMutexGuard for a component of the locked data.

This operation cannot fail as the MappedMutexGuard passed in already locked the mutex.

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 locked data.

fn try_map<U, F>(this: Self, f: F) -> Result<MappedMutexGuard<'a, U>, Self>
where
    F: FnOnce(&mut T) -> Option<&mut U>,

Attempts to make a new MappedMutexGuard for a component of the locked data. The original guard is returned if the closure returns None.

This operation cannot fail as the MappedMutexGuard passed in already locked the mutex.

This is an associated function that needs to be used as MappedMutexGuard::try_map(...). A method would interfere with methods of the same name on the contents of the locked data.

Trait Implementations

impl<'a, T> Send for MappedMutexGuard<'a, T> where T: ?Sized + Send + 'a,

impl<'a, T> Sync for MappedMutexGuard<'a, T> where T: ?Sized + Sync + 'a,

impl<'a, T: ?Sized + Debug> Debug for MappedMutexGuard<'a, T>

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

impl<'a, T: ?Sized + Display> Display for MappedMutexGuard<'a, T>

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

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

type Target = T;
fn deref(&self) -> &Self::Target

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

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

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

fn drop(&mut self)

Auto Trait Implementations

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

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

impl<'a, T> Freeze for MappedMutexGuard<'a, T> where *mut T: Freeze, PhantomData<&'a mut T>: Freeze, T: ?Sized,

impl<'a, T> Unpin for MappedMutexGuard<'a, T> where *mut T: Unpin, PhantomData<&'a mut T>: Unpin, T: ?Sized,

impl<'a, T> UnsafeUnpin for MappedMutexGuard<'a, T> where *mut T: UnsafeUnpin, PhantomData<&'a mut T>: UnsafeUnpin, T: ?Sized,

Blanket Implementations

impl<P, T> Receiver for MappedMutexGuard<'a, T> where P: Deref<Target = T> + ?Sized, T: ?Sized,

type Target = T;

impl<T> Any for MappedMutexGuard<'a, T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for MappedMutexGuard<'a, T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for MappedMutexGuard<'a, T> where T: ?Sized,

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

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

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToString for MappedMutexGuard<'a, T> where T: Display + ?Sized,

fn to_string(&self) -> String

impl<T, U> Into<U> for MappedMutexGuard<'a, T> where 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<T, U> TryFrom<U> for MappedMutexGuard<'a, T> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for MappedMutexGuard<'a, T> where U: TryFrom<T>,

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