[][src]Trait tap::TapOps

pub trait TapOps: Sized {
    fn tap<R, F>(self, f: F) -> Self
    where
        F: FnOnce(&mut Self) -> R
; }

Tap operations for all types.

Required methods

fn tap<R, F>(self, f: F) -> Self where
    F: FnOnce(&mut Self) -> R, 

Executes a closure on an object, discarding the result.

Examples

let mut max = 0;
let data: [u32; 5] = [2, 8, 3, 4, 0];
assert_eq!(
    data.tap(|x| x.sort()).tap(|x| max += x.last().unwrap()), 
    [0, 2, 3, 4, 8]
);
assert_eq!(max, 8);
Loading content...

Implementors

impl<T> TapOps for T where
    T: Sized
[src]

Loading content...