[−][src]Trait guard_trait::GuardedExt
An extension trait for convenience methods, that is automatically implemented for all
Guarded
types.
Provided methods
fn map<F, T>(this: Self, f: F) -> Mapped<Self, T> where
F: FnOnce(&Self::Target) -> &T,
T: ?Sized,
F: FnOnce(&Self::Target) -> &T,
T: ?Sized,
Apply a function to the pointee, creating a new guarded type that dereferences into the result of that function.
The closure is only evaluated once, and the resulting wrapper will only store one null-optimizable additional word, for the reference.
fn try_map<F, T, E>(this: Self, f: F) -> Result<Mapped<Self, T>, E> where
F: FnOnce(&Self::Target) -> Result<&T, E>,
T: ?Sized,
F: FnOnce(&Self::Target) -> Result<&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.