GuardedMutExt

Trait GuardedMutExt 

Source
pub trait GuardedMutExt:
    Sealed
    + GuardedMut
    + Sized {
    // Provided methods
    fn map_mut<F, T>(this: Self, f: F) -> MappedMut<Self, T>
       where F: FnOnce(&mut <Self as Guarded>::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 as Guarded>::Target) -> Result<&mut T, E>,
             T: ?Sized { ... }
}
Expand description

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

Provided Methods§

Source

fn map_mut<F, T>(this: Self, f: F) -> MappedMut<Self, T>
where F: FnOnce(&mut <Self as Guarded>::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.

Source

fn try_map_mut<F, T, E>(this: Self, f: F) -> Result<MappedMut<Self, T>, E>
where F: FnOnce(&mut <Self as Guarded>::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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> GuardedMutExt for T
where T: GuardedMut + Sized,