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 { ... } }
Expand description

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

Provides the interior value for inspection if present.

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

Provides the interior value for modification if present.

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

Runs the provided function if the Option is empty.

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

Provided methods

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

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

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

Implementations on Foreign Types

Implementors