OptionExt

Trait OptionExt 

Source
pub trait OptionExt<T> {
    // Required method
    fn ok_or_err_msg(self, msg: &'static str) -> Result<T, Error>;
}
Expand description

An extension to Option to allow turning None case to an Error from a static string (handy for WASM).

Required Methods§

Source

fn ok_or_err_msg(self, msg: &'static str) -> Result<T, Error>

Transforms the Option<T> into a Result<T>, mapping [Some(v)] to [Ok(v)] and None to the given static error message.

Implementations on Foreign Types§

Source§

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

Source§

fn ok_or_err_msg(self, msg: &'static str) -> Result<T, Error>

Implementors§