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.