pub trait Tap4Ref {
// Provided methods
fn tap4_with<'x, X: ?Sized + 'x, R, A1, A2, A3, A4>(
&'x self,
proj: impl FnOnce(&'x Self) -> &'x X,
f: impl FnOnce(&'x X, A1, A2, A3, A4) -> R,
) -> impl FnOnce(A1, A2, A3, A4) -> &'x Self { ... }
fn tap4_with_mut<'x, X: ?Sized + 'x, M, F, A1, A2, A3, A4>(
&'x mut self,
proj: impl FnOnce(&mut Self) -> &mut X,
f: F,
) -> impl FnOnce(A1, A2, A3, A4) -> &'x mut Self
where F: Tap4Fn<X, A1, A2, A3, A4, M> { ... }
}Expand description
Tap-style helpers for calling (first, A1..A4) -> R for side effects.
The tap4_with* methods call f with a (possibly projected) borrow of self, discard R, and return self to enable chaining.
Provided Methods§
Sourcefn tap4_with<'x, X: ?Sized + 'x, R, A1, A2, A3, A4>(
&'x self,
proj: impl FnOnce(&'x Self) -> &'x X,
f: impl FnOnce(&'x X, A1, A2, A3, A4) -> R,
) -> impl FnOnce(A1, A2, A3, A4) -> &'x Self
fn tap4_with<'x, X: ?Sized + 'x, R, A1, A2, A3, A4>( &'x self, proj: impl FnOnce(&'x Self) -> &'x X, f: impl FnOnce(&'x X, A1, A2, A3, A4) -> R, ) -> impl FnOnce(A1, A2, A3, A4) -> &'x Self
Calls f(proj(&self), a1..a4) (immutable view), discards the return value, and returns &self.
Sourcefn tap4_with_mut<'x, X: ?Sized + 'x, M, F, A1, A2, A3, A4>(
&'x mut self,
proj: impl FnOnce(&mut Self) -> &mut X,
f: F,
) -> impl FnOnce(A1, A2, A3, A4) -> &'x mut Selfwhere
F: Tap4Fn<X, A1, A2, A3, A4, M>,
fn tap4_with_mut<'x, X: ?Sized + 'x, M, F, A1, A2, A3, A4>(
&'x mut self,
proj: impl FnOnce(&mut Self) -> &mut X,
f: F,
) -> impl FnOnce(A1, A2, A3, A4) -> &'x mut Selfwhere
F: Tap4Fn<X, A1, A2, A3, A4, M>,
Calls f(proj(&mut self), a1..a4) (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.