[−][src]Trait failure_ext::OptionExt
Extension methods for Option
.
Required methods
fn ok_or_context<D>(self, context: D) -> Result<T, Context<D>> where
D: Display + Send + Sync + 'static,
D: Display + Send + Sync + 'static,
Wraps the error type in a context type.
Examples
let opt: Option<String> = None; let x = opt.ok_or_context(format!("An error occured")).unwrap_err(); let x = format!("{}", x); assert_eq!(x, "An error occured");
Implementations on Foreign Types
impl<T> OptionExt<T> for Option<T>
[src]
fn ok_or_context<D>(self, context: D) -> Result<T, Context<D>> where
D: Display + Send + Sync + 'static,
[src]
D: Display + Send + Sync + 'static,