pub trait OptionExt<T> { // Required method fn ok_or_err_msg(self, msg: &'static str) -> Result<T, Error>; }
An extension to Option to allow turning None case to an Error from a static string (handy for WASM).
Option
None
Transforms the Option<T> into a Result<T>, mapping [Some(v)] to [Ok(v)] and None to the given static error message.
Option<T>
Result<T>
Some(v)
Ok(v)