Skip to main content

MaybeExt

Trait MaybeExt 

Source
pub trait MaybeExt<T> {
    // Required methods
    fn to_result<E>(self, err: E) -> Result<T, E>;
    fn try_unwrap(self) -> ComposableResult<T, &'static str>;
}
Expand description

Extension trait for Maybe that provides additional error handling methods

Required Methods§

Source

fn to_result<E>(self, err: E) -> Result<T, E>

Converts a Maybe to a Result with the specified error

Source

fn try_unwrap(self) -> ComposableResult<T, &'static str>

Provides a safe unwrapping mechanism that returns a Result.

On Nothing, this returns an Err containing a ComposableError<&'static str> with context explaining the failure.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> MaybeExt<T> for Maybe<T>