ok_or_return

Macro ok_or_return 

Source
macro_rules! ok_or_return {
    ($e:expr) => { ... };
    ($e:expr, $r: expr) => { ... };
    ($e:expr, $return_value: expr, $log_info: expr) => { ... };
}
Expand description

Unwrap arguments when it represents (Ok).

otherwise will return ([()]) or second arguments.

§Examples


#[macro_use]
extern crate unwrap_goto;
 
fn when_err_and_return() {
    let x: Result<i32, &str> = Err("Some error message");
    ok_or_return!(x);
    println!("anything print out:{:?}", x);
}