[−][src]Trait wyz::tap::TapOption
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
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
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
Runs the provided function if the Option
is empty.
This is equivalent to .or_else(|| { func(); None })
.
Provided methods
fn tap_some_dbg<F: FnOnce(&T) -> R, R>(self, func: F) -> Self
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
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
Calls tap_none
in debug builds, and does nothing in release builds.