Skip to main content

OptionContext

Trait OptionContext 

Source
pub trait OptionContext<T> {
    // Required methods
    fn context_none(self, context: impl Into<String>) -> Result<T>;
    fn with_context_none<F, C>(self, f: F) -> Result<T>
       where F: FnOnce() -> C,
             C: Into<String>;
}
Expand description

Extension trait for Option types to convert to errors with context.

Required Methods§

Source

fn context_none(self, context: impl Into<String>) -> Result<T>

Convert None to an error with the given context.

Source

fn with_context_none<F, C>(self, f: F) -> Result<T>
where F: FnOnce() -> C, C: Into<String>,

Convert None to an error with context from a closure.

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> OptionContext<T> for Option<T>

Source§

fn context_none(self, context: impl Into<String>) -> Result<T>

Source§

fn with_context_none<F, C>(self, f: F) -> Result<T>
where F: FnOnce() -> C, C: Into<String>,

Implementors§