pub trait PipeBorrow {
    fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
    where
        Self: Borrow<T>,
        T: 'a,
        R: 'a + Sized
, { ... }
fn pipe_borrow_mut<'a, T, R>(
        &'a mut self,
        func: impl FnOnce(&'a mut T) -> R
    ) -> R
    where
        Self: BorrowMut<T>,
        T: 'a,
        R: 'a + Sized
, { ... } }
Expand description

Calls the Borrow or BorrowMut traits before piping.

Provided methods

Pipes a trait borrow into a function that cannot normally be called in suffix position.

Parameters
  • &self: A borrow of the receiver. By automatically borrowing, this pipe call ensures that the lifetime of the origin object is not artificially truncated.
  • func: A function which receives a trait-directed borrow of the receiver’s value type. Before this function is called, <Self as Borrow<T>::borrow> is called on the self reference, and the output of that trait borrow is passed to func.
Type Parameters
  • T: The type to which self Borrows. This is required to be defined as a method type parameter so that you can disambiguate at call time.
  • R: The return type of func.
Lifetimes
  • 'a: The lifetime of the self value. .pipe_mut borrows self for the duration 'a, and extends it through the return value of func.

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position.

Parameters
  • &mut self: A mutable borrow of the receiver. By automatically borrowing, this pipe call ensures that the lifetime of the origin object is not artificially truncated.
  • func: A function which receives a trait-directed borrow of the receiver’s value type. Before this function is called, <Self as BorrowMut<T>::borrow_mut> is called on the self reference, and the output of that trait borrow is passed to func.
Type Parameters
  • T: The type to which self borrows. This is required to be defined as a method type parameter so that you can disambiguate at call time.
  • R: The return type of func.
Lifetimes
  • 'a: The lifetime of the self value. .pipe_mut borrows self for the duration 'a, and extends it through the return value of func.

Implementors