Skip to main content

Tap

Trait Tap 

Source
pub trait Tap<const ARITY: usize, AState, RState> {
    // Provided method
    fn tap<'a, R, F, Args>(self, f: F) -> F::Curry<'a>
       where F: ImplCurry<ARITY, Args, AState, RState, TapMark, Self, R>,
             Self: Sized { ... }
}
Expand description

Extension trait for running side effects without altering the pipeline value.

Provided Methods§

Source

fn tap<'a, R, F, Args>(self, f: F) -> F::Curry<'a>
where F: ImplCurry<ARITY, Args, AState, RState, TapMark, Self, R>, Self: Sized,

Runs a side-effect and returns the original value.

Supports both immutable and mutable operations on the value.

§Example
let x = 10
    .tap(|x: &mut i32, n| *x += n)(5);
assert_eq!(x, 15);

Implementors§

Source§

impl<const ARITY: usize, AState, RState, T> Tap<ARITY, AState, RState> for T