[−][src]Trait tap::TapOps
Tap operations for all types.
Required methods
fn tap<R, F>(self, f: F) -> Self where
F: FnOnce(&mut Self) -> R,
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);