Trait wyz::tap::TapOption[][src]

pub trait TapOption<T: Sized>: Sized {
    fn tap_some<F: FnOnce(&T) -> R, R>(self, func: F) -> Self;
fn tap_some_mut<F: FnOnce(&mut T) -> R, R>(self, func: F) -> Self;
fn tap_none<F: FnOnce() -> R, R>(self, func: F) -> Self; fn tap_some_dbg<F: FnOnce(&T) -> R, R>(self, func: F) -> Self { ... }
fn tap_some_mut_dbg<F: FnOnce(&mut T) -> R, R>(self, func: F) -> Self { ... }
fn tap_none_dbg<F: FnOnce() -> R, R>(self, func: F) -> Self { ... } }

Optional Tap

This trait allows conditional tapping of Option wrappers. The methods only invoke their provided function, on the inner type, if the Option has the correct outer variant.

Required methods

fn tap_some<F: FnOnce(&T) -> R, R>(self, func: F) -> Self[src]

Provides the interior value for inspection if present.

This is equivalent to .map(|v| { func(&v); v }).

fn tap_some_mut<F: FnOnce(&mut T) -> R, R>(self, func: F) -> Self[src]

Provides the interior value for modification if present.

This is equivalent to .map(|mut v| { func(&mut v); v }).

fn tap_none<F: FnOnce() -> R, R>(self, func: F) -> Self[src]

Runs the provided function if the Option is empty.

This is equivalent to .or_else(|| { func(); None }).

Loading content...

Provided methods

fn tap_some_dbg<F: FnOnce(&T) -> R, R>(self, func: F) -> Self[src]

Calls tap_some in debug builds, and does nothing in release builds.

fn tap_some_mut_dbg<F: FnOnce(&mut T) -> R, R>(self, func: F) -> Self[src]

Calls tap_some_mut in debug builds, and does nothing in release builds.

fn tap_none_dbg<F: FnOnce() -> R, R>(self, func: F) -> Self[src]

Calls tap_none in debug builds, and does nothing in release builds.

Loading content...

Implementations on Foreign Types

impl<T> TapOption<T> for Option<T>[src]

Loading content...

Implementors

Loading content...