[][src]Trait guard_trait::GuardedMutExt

pub trait GuardedMutExt: Sealed + GuardedMut + Sized {
    fn map_mut<F, T>(this: Self, f: F) -> MappedMut<Self, T>
    where
        F: FnOnce(&mut Self::Target) -> &mut T,
        T: ?Sized
, { ... }
fn try_map_mut<F, T, E>(this: Self, f: F) -> Result<MappedMut<Self, T>, E>
    where
        F: FnOnce(&mut Self::Target) -> Result<&mut T, E>,
        T: ?Sized
, { ... } }

An extension trait for convenience methods, that is automatically implemented for all GuardedMut types.

Provided methods

fn map_mut<F, T>(this: Self, f: F) -> MappedMut<Self, T> where
    F: FnOnce(&mut Self::Target) -> &mut T,
    T: ?Sized

Apply a function to the pointee, creating a new guarded type that dereferences into the result of that function.

This is the mutable version of GuardedExt::map. Because of this mutability, the original pointer cannot be accessed until it is completely moved out of the wrapper.

fn try_map_mut<F, T, E>(this: Self, f: F) -> Result<MappedMut<Self, T>, E> where
    F: FnOnce(&mut Self::Target) -> Result<&mut T, E>,
    T: ?Sized

Apply a fallible function to the pointee, creating a new guarded type that dereferences into the result of that function.

If the function fails, the error is returned directly, and no further mapping is made.

Loading content...

Implementors

impl<T> GuardedMutExt for T where
    T: GuardedMut + Sized
[src]

Loading content...