[][src]Trait tap::TapBooleanOps

pub trait TapBooleanOps {
    fn tap_true<R, F: FnOnce() -> R>(self, f: F) -> Self;
fn tap_false<R, F: FnOnce() -> R>(self, f: F) -> Self; }

Tap operations for bool.

Required methods

fn tap_true<R, F: FnOnce() -> R>(self, f: F) -> Self

Executes a closure if self is true.

Examples

let mut foo = 0;
let boolean = false;
assert_eq!(boolean.tap_true(|| foo += 5), false);
assert_eq!(foo, 0);
let mut foo = 0;
let boolean = true;
assert_eq!(boolean.tap_true(|| foo += 5), true);
assert_eq!(foo, 5);

fn tap_false<R, F: FnOnce() -> R>(self, f: F) -> Self

Executes a closure if self is false.

Examples

let mut foo = 0;
let boolean = false;
assert_eq!(boolean.tap_false(|| foo += 5), false);
assert_eq!(foo, 5);
let mut foo = 0;
let boolean = true;
assert_eq!(boolean.tap_false(|| foo += 5), true);
assert_eq!(foo, 0);
Loading content...

Implementations on Foreign Types

impl TapBooleanOps for bool[src]

Loading content...

Implementors

Loading content...