Trait OptionSomeExt

Source
pub trait OptionSomeExt {
    type Item;

    // Required method
    fn some(self) -> Result<Self::Item, NoneError>;
}
Expand description

An extension trait that allows you to convert Option<T> into Result<T, NoneError> simply by calling opt.some().

Particularly useful with type-erased error handling such as Box<dyn Error> or anyhow::Error. The error type contains the source code location of where some() was erroneously called, for easy debugging.

Required Associated Types§

Required Methods§

Source

fn some(self) -> Result<Self::Item, NoneError>

Implementations on Foreign Types§

Source§

impl<T> OptionSomeExt for Option<T>

Source§

type Item = T

Source§

fn some(self) -> Result<Self::Item, NoneError>

Implementors§