OptionExt

Trait OptionExt 

Source
pub trait OptionExt {
    type Some;

    // Required methods
    fn ok_or_raise<A, F>(self, err: F) -> Result<Self::Some, Exn<A>>
       where A: Error + Send + Sync + 'static,
             F: FnOnce() -> A;
    fn ok_or_raise_erased<A, F>(self, err: F) -> Result<Self::Some, Exn>
       where A: Error + Send + Sync + 'static,
             F: FnOnce() -> A;
}
Expand description

An extension trait for Option to provide raising new exceptions on None.

Required Associated Types§

Source

type Some

The Some type.

Required Methods§

Source

fn ok_or_raise<A, F>(self, err: F) -> Result<Self::Some, Exn<A>>
where A: Error + Send + Sync + 'static, F: FnOnce() -> A,

Construct a new Exn on the None variant.

Source

fn ok_or_raise_erased<A, F>(self, err: F) -> Result<Self::Some, Exn>
where A: Error + Send + Sync + 'static, F: FnOnce() -> A,

Construct a new Exn on the None variant, with type erasure.

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

Source§

type Some = T

Source§

fn ok_or_raise<A, F>(self, err: F) -> Result<T, Exn<A>>
where A: Error + Send + Sync + 'static, F: FnOnce() -> A,

Source§

fn ok_or_raise_erased<A, F>(self, err: F) -> Result<T, Exn>
where A: Error + Send + Sync + 'static, F: FnOnce() -> A,

Implementors§