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 })
.
fn tap_some_mut<F: FnOnce(&mut T) -> R, R>(self, func: F) -> Self
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 })
.
Provided methods
fn tap_some_dbg<F: FnOnce(&T) -> R, R>(self, func: F) -> Self
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
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
fn tap_none_dbg<F: FnOnce() -> R, R>(self, func: F) -> Self
Calls tap_none
in debug builds, and does nothing in release builds.