Skip to main content

OptionExt

Trait OptionExt 

Source
pub trait OptionExt<T> {
    // Required methods
    fn or_not_found(self, message: impl Into<Cow<'static, str>>) -> Result<T>;
    fn or_error(self, error: Error) -> Result<T>;
}
Expand description

Conversions from Options into Kerniq errors.

Required Methods§

Source

fn or_not_found(self, message: impl Into<Cow<'static, str>>) -> Result<T>

Maps None to a 404 Not Found with the given public message.

Source

fn or_error(self, error: Error) -> Result<T>

Maps None to the given error.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T> OptionExt<T> for Option<T>

Source§

fn or_not_found(self, message: impl Into<Cow<'static, str>>) -> Result<T>

Source§

fn or_error(self, error: Error) -> Result<T>

Implementors§