macro_rules! unwrap_or_do {
    ($exp: expr, $do: expr) => { ... };
}
Expand description

If it’s not what you want, then do what you want

Examples

use what_i_want::*;

let an_err: Result<Option<i32>, ()> = Ok(Some(1));
let an_option: Option<Option<i32>> = Some(Some(1));

unwrap_or_do!(an_err, Some(0));
unwrap_or_do!(an_option, Some(0));

fn a_func() -> bool {
    let an_option = Some(true);
    unwrap_or_do!(an_option, return false)
}