Macro vipers::unwrap_or_err[][src]

macro_rules! unwrap_or_err {
    ($option : expr, $error : tt $(,) ?) => { ... };
}
Expand description

Ensures an Option can be unwrapped, otherwise returns the error.

Example

let one = 1_u64;
let two = 2_u64;
let my_value = unwrap_or_err!(one.checked_sub(2), MyError); // throws an error
Ok(())