pub trait Pipe2Ref {
// Provided methods
fn pipe2_with<'x, X: ?Sized + 'x, R: 'x, A1, A2>(
&'x self,
proj: impl FnOnce(&'x Self) -> &'x X,
f: impl FnOnce(&'x X, A1, A2) -> R,
) -> impl FnOnce(A1, A2) -> R { ... }
fn pipe2_with_mut<'x, X: ?Sized + 'x, R: 'x, A1, A2>(
&'x mut self,
proj: impl FnOnce(&'x mut Self) -> &'x mut X,
f: impl FnOnce(&'x mut X, A1, A2) -> R,
) -> impl FnOnce(A1, A2) -> R { ... }
}Expand description
Pipe-style helpers for partial application of (first, A1..A2) -> R functions.
The pipe2_with* methods fix the first argument to a (possibly projected) borrow of self and return a closure that accepts the remaining 2 arguments.
Provided Methods§
Sourcefn pipe2_with<'x, X: ?Sized + 'x, R: 'x, A1, A2>(
&'x self,
proj: impl FnOnce(&'x Self) -> &'x X,
f: impl FnOnce(&'x X, A1, A2) -> R,
) -> impl FnOnce(A1, A2) -> R
fn pipe2_with<'x, X: ?Sized + 'x, R: 'x, A1, A2>( &'x self, proj: impl FnOnce(&'x Self) -> &'x X, f: impl FnOnce(&'x X, A1, A2) -> R, ) -> impl FnOnce(A1, A2) -> R
Partially applies f by fixing its first argument to proj(&self), returning a closure that takes (A1..A2).
Semantics: self.pipe2_with(proj, f)(a1..a2) == f(proj(&self), a1..a2).
Sourcefn pipe2_with_mut<'x, X: ?Sized + 'x, R: 'x, A1, A2>(
&'x mut self,
proj: impl FnOnce(&'x mut Self) -> &'x mut X,
f: impl FnOnce(&'x mut X, A1, A2) -> R,
) -> impl FnOnce(A1, A2) -> R
fn pipe2_with_mut<'x, X: ?Sized + 'x, R: 'x, A1, A2>( &'x mut self, proj: impl FnOnce(&'x mut Self) -> &'x mut X, f: impl FnOnce(&'x mut X, A1, A2) -> R, ) -> impl FnOnce(A1, A2) -> R
Partially applies f by fixing its first argument to proj(&mut self), returning a closure that takes (A1..A2).
Semantics: self.pipe2_with_mut(proj, f)(a1..a2) == f(proj(&mut self), a1..a2).
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.