Macro mac::unwrap_or_return [] [src]

macro_rules! unwrap_or_return {
    ($e:expr, $r:expr) => { ... };
}

Unwraps an Option or returns from the function with the specified return value.

Can be used on Results by first calling .ok() or .err() on them.

Examples

fn take_pair<I:Iterator>(iter: &mut I) -> Option<(<I as Iterator>::Item, <I as Iterator>::Item)> {
   let first = unwrap_or_return!(iter.next(), None);
   Some((first, unwrap_or_return!(iter.next(), None)))
}