Pipe4Ref

Trait Pipe4Ref 

Source
pub trait Pipe4Ref {
    // Provided methods
    fn pipe4_with<'x, X: ?Sized + 'x, R: 'x, 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) -> R { ... }
    fn pipe4_with_mut<'x, X: ?Sized + 'x, R: 'x, A1, A2, A3, A4>(
        &'x mut self,
        proj: impl FnOnce(&'x mut Self) -> &'x mut X,
        f: impl FnOnce(&'x mut X, A1, A2, A3, A4) -> R,
    ) -> impl FnOnce(A1, A2, A3, A4) -> R { ... }
}
Expand description

Pipe-style helpers for partial application of (first, A1..A4) -> R functions.

The pipe4_with* methods fix the first argument to a (possibly projected) borrow of self and return a closure that accepts the remaining 4 arguments.

Provided Methods§

Source

fn pipe4_with<'x, X: ?Sized + 'x, R: 'x, 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) -> R

Partially applies f by fixing its first argument to proj(&self), returning a closure that takes (A1..A4).

Semantics: self.pipe4_with(proj, f)(a1..a4) == f(proj(&self), a1..a4).

Source

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

Partially applies f by fixing its first argument to proj(&mut self), returning a closure that takes (A1..A4).

Semantics: self.pipe4_with_mut(proj, f)(a1..a4) == f(proj(&mut self), a1..a4).

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> Pipe4Ref for T