pub trait OptionFault<T> {
// Required methods
fn ok_or_fault(self) -> Result<T, Fault>;
fn ok_or_fault_force(self) -> Result<T, Fault>;
}
Expand description
To use this trait on Option import the prelude use explicit_error::prelude::*
Required Methods§
Sourcefn ok_or_fault(self) -> Result<T, Fault>
fn ok_or_fault(self) -> Result<T, Fault>
Transforms the Option<T>
into a Result<T, Fault>
, mapping Some(v) to Ok(v) and None to Err(Fault)
fn foo() -> Result<(), Error> {
let option: Option<u8> = None;
option.ok_or_fault().with_context("Help debugging")?;
}
Sourcefn ok_or_fault_force(self) -> Result<T, Fault>
fn ok_or_fault_force(self) -> Result<T, Fault>
Transforms the Option<T>
into a Result<T, Fault>
, mapping Some(v) to Ok(v) and None to Err(Fault)
forcing backtrace capture
fn foo() -> Result<(), Error> {
let option: Option<u8> = None;
option.ok_or_fault_force().with_context("Help debugging")?;
}