Tap2Ref

Trait Tap2Ref 

Source
pub trait Tap2Ref {
    // Provided methods
    fn tap2_with<'x, X: ?Sized + 'x, R, A1, A2>(
        &'x self,
        proj: impl FnOnce(&'x Self) -> &'x X,
        f: impl FnOnce(&'x X, A1, A2) -> R,
    ) -> impl FnOnce(A1, A2) -> &'x Self { ... }
    fn tap2_with_mut<'x, X: ?Sized + 'x, M, F, A1, A2>(
        &'x mut self,
        proj: impl FnOnce(&mut Self) -> &mut X,
        f: F,
    ) -> impl FnOnce(A1, A2) -> &'x mut Self
       where F: Tap2Fn<X, A1, A2, M> { ... }
}
Expand description

Tap-style helpers for calling (first, A1..A2) -> R for side effects.

The tap2_with* methods call f with a (possibly projected) borrow of self, discard R, and return self to enable chaining.

Provided Methods§

Source

fn tap2_with<'x, X: ?Sized + 'x, R, A1, A2>( &'x self, proj: impl FnOnce(&'x Self) -> &'x X, f: impl FnOnce(&'x X, A1, A2) -> R, ) -> impl FnOnce(A1, A2) -> &'x Self

Calls f(proj(&self), a1..a2) (immutable view), discards the return value, and returns &self.

Source

fn tap2_with_mut<'x, X: ?Sized + 'x, M, F, A1, A2>( &'x mut self, proj: impl FnOnce(&mut Self) -> &mut X, f: F, ) -> impl FnOnce(A1, A2) -> &'x mut Self
where F: Tap2Fn<X, A1, A2, M>,

Calls f(proj(&mut self), a1..a2) (mutable view), discards the return value, and returns &mut self.

This method accepts both immutable Fn(&X) and mutable Fn(&mut X) functions.

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: ?Sized> Tap2Ref for T