pub trait TapOptional where
    Self: Sized
{ type Val: ?Sized; fn tap_some(self, func: impl FnOnce(&Self::Val)) -> Self;
fn tap_some_mut(self, func: impl FnOnce(&mut Self::Val)) -> Self;
fn tap_none(self, func: impl FnOnce()) -> Self; fn tap_some_dbg(self, func: impl FnOnce(&Self::Val)) -> Self { ... }
fn tap_some_mut_dbg(self, func: impl FnOnce(&mut Self::Val)) -> Self { ... }
fn tap_none_dbg(self, func: impl FnOnce()) -> Self { ... } }
Expand description

Optional tapping, conditional on the optional presence of a value.

This trait is intended for use on types that express the concept of “optional presence”, primarily the Option monad. It provides taps that inspect the container to determine if the effect function should execute or not.

Note: This trait is a specialization of TapFallible, and exists because the std::ops::Try trait is still unstable. When Try stabilizes, this trait can be removed, and TapFallible blanket-applied to all Try implementors.

Associated Types

The interior type that the container may or may not carry.

Required methods

Immutabily accesses an interior value only when it is present.

This function is identical to Tap::tap, except that it is required to check the implementing container for value presence before running. Implementors must not run the effect function if the container is marked as being empty.

Mutably accesses an interor value only when it is present.

This function is identical to Tap::tap_mut, except that it is required to check the implementing container for value presence before running. Implementors must not run the effect function if the container is marked as being empty.

Runs an effect function when the container is empty.

This function is identical to Tap::tap, except that it is required to check the implementing container for value absence before running. Implementors must not run the effect function if the container is marked as being non-empty.

Provided methods

Calls .tap_some() only in debug builds, and is erased in release builds.

Calls .tap_some_mut() only in debug builds, and is erased in release builds.

Calls .tap_none() only in debug builds, and is erased in release builds.

Implementations on Foreign Types

Implementors