ok_or_break

Macro ok_or_break 

Source
macro_rules! ok_or_break {
    ($from:expr) => { ... };
    ($from:expr, $lt:lifetime) => { ... };
}
Expand description

Either get the Ok value from a Result type or break out of a loop. If a loop lifetime is specified, that loop will be exited, otherwise the immediate loop is exited.

use early_returns::ok_or_break;
fn do_something_with_option(vals: &Vec<Result<i32, ()>>) {
    for val in vals {
        let val = ok_or_break!(val);
        println!("{}", val);
    }

    'l: for val in vals {
        for i in 0..5 {
            let val = ok_or_break!(val, 'l);
            println!("{}", val + i);
        }
    }
}