[][src]Struct guard_trait::Mapped

pub struct Mapped<T, U> where
    T: Guarded,
    U: ?Sized
{ /* fields omitted */ }

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]

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]

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]

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]

impl<T, U> Guarded for Mapped<T, U> where
    T: Guarded,
    U: ?Sized
[src]

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

Auto Trait Implementations

impl<T, U: ?Sized> RefUnwindSafe for Mapped<T, U> where
    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

impl<T, U: ?Sized> UnwindSafe for Mapped<T, U> where
    T: UnwindSafe,
    U: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Guarded for T where
    T: Deref<Target = U> + StableDeref + 'static,
    U: ?Sized
[src]

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

impl<T> GuardedExt for T where
    T: Guarded
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.