[−][src]Struct guard_trait::Mapped
A mapped guard, which contains a guarded owned pointer, and an immutable reference to that
pointer. It has had a one-time closure applied to it, but only the output of the closure is
stored, not the closure itself. This is similar to how crates like owning_ref
work.
Implementations
impl<T, U> Mapped<T, U> where
T: Guarded,
U: ?Sized,
[src]
T: Guarded,
U: ?Sized,
pub fn into_original(self) -> T
[src]
Move the inner guarded pointer out from the Mapped
wrapper, cancelling the temporary
borrow.
pub fn original_by_ref(&self) -> &T
[src]
Get the original pointer, by immutable reference.
pub fn get_ref(&self) -> &U
[src]
Retrieve an immutable reference to the mapped data.
pub fn and_then<F, V>(self, f: F) -> Mapped<T, V> where
F: FnOnce(&U) -> &V,
V: ?Sized,
[src]
F: FnOnce(&U) -> &V,
V: ?Sized,
Map the mapped wrapper again, converting &U
to &V
.
pub fn try_and_then<F, V, E>(self, f: F) -> Result<Mapped<T, V>, E> where
F: FnOnce(&U) -> Result<&V, E>,
V: ?Sized,
[src]
F: FnOnce(&U) -> Result<&V, E>,
V: ?Sized,
Attempt to map the reference again, but with the ability to short-circuit on errors.
Trait Implementations
impl<T, U: ?Sized> Debug for Mapped<T, U> where
T: Guarded,
U: Debug,
[src]
T: Guarded,
U: Debug,
impl<T, U> Guarded for Mapped<T, U> where
T: Guarded,
U: ?Sized,
[src]
T: Guarded,
U: ?Sized,
type Target = U
The target pointee that this pointer may dereference into. There are no real restrictions
to what this type can be. However, the user must not assume that simply because a &Target
reference is protected, that references indirectly derived (via Deref
and other traits)
would also be protected. Read more
fn borrow_guarded(&self) -> &Self::Target
[src]
Auto Trait Implementations
impl<T, U: ?Sized> RefUnwindSafe for Mapped<T, U> where
T: RefUnwindSafe,
U: RefUnwindSafe,
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> !Send for Mapped<T, U>
impl<T, U> !Sync for Mapped<T, U>
impl<T, U: ?Sized> Unpin for Mapped<T, U> where
T: Unpin,
T: Unpin,
impl<T, U: ?Sized> UnwindSafe for Mapped<T, U> where
T: UnwindSafe,
U: RefUnwindSafe,
T: UnwindSafe,
U: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Guarded for T where
T: Deref<Target = U> + StableDeref + 'static,
U: ?Sized,
[src]
T: Deref<Target = U> + StableDeref + 'static,
U: ?Sized,
type Target = U
The target pointee that this pointer may dereference into. There are no real restrictions
to what this type can be. However, the user must not assume that simply because a &Target
reference is protected, that references indirectly derived (via Deref
and other traits)
would also be protected. Read more
pub fn borrow_guarded(&Self) -> &U
[src]
impl<T> GuardedExt for T where
T: Guarded,
[src]
T: Guarded,
fn map<F, T>(this: Self, f: F) -> Mapped<Self, T> where
F: FnOnce(&Self::Target) -> &T,
T: ?Sized,
[src]
F: FnOnce(&Self::Target) -> &T,
T: ?Sized,
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,
[src]
F: FnOnce(&Self::Target) -> Result<&T, E>,
T: ?Sized,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,