DMSCOptionErrorContext

Trait DMSCOptionErrorContext 

Source
pub trait DMSCOptionErrorContext<T> {
    // Required methods
    fn ok_or_chain<E>(self, err: E) -> Result<T, DMSCErrorChain>
       where E: StdError + Send + Sync + 'static;
    fn ok_or_else_chain<E, F>(self, f: F) -> Result<T, DMSCErrorChain>
       where E: StdError + Send + Sync + 'static,
             F: FnOnce() -> E;
}
Expand description

Extension trait for adding error context to Option types.

Required Methods§

Source

fn ok_or_chain<E>(self, err: E) -> Result<T, DMSCErrorChain>
where E: StdError + Send + Sync + 'static,

Converts None to an error with context.

Source

fn ok_or_else_chain<E, F>(self, f: F) -> Result<T, DMSCErrorChain>
where E: StdError + Send + Sync + 'static, F: FnOnce() -> E,

Converts None to an error with lazy context.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> DMSCOptionErrorContext<T> for Option<T>

Source§

fn ok_or_chain<E>(self, err: E) -> Result<T, DMSCErrorChain>
where E: StdError + Send + Sync + 'static,

Source§

fn ok_or_else_chain<E, F>(self, f: F) -> Result<T, DMSCErrorChain>
where E: StdError + Send + Sync + 'static, F: FnOnce() -> E,

Implementors§