[][src]Macro postfix_macros::match_or

macro_rules! match_or {
    ($v:expr, $($pat:pat => $e:expr)+ ; $($else:tt)*) => { ... };
}

match macro with a default case shorthand

Meant to be used in a postfix context, as the postfix analog of match and if let Rust constructs.

#[derive(Copy, Clone)]
enum Foo {
	Bar(u8),
	Baz,
}
let v = Foo::Bar(42);
let mut w = 0;
for i in 0..3 {
	w += i;
	v.match_or!{ Foo::Bar(x) => x; break };
}
assert_eq!(w, 3);