Skip to content

Instantly share code, notes, and snippets.

@wackywendell
Last active August 29, 2015 14:03
Show Gist options
  • Save wackywendell/c5330d75da9c4c5795c0 to your computer and use it in GitHub Desktop.
Save wackywendell/c5330d75da9c4c5795c0 to your computer and use it in GitHub Desktop.
Fails to compile with "rustc --opt-level 3 macro_test.rs" but compiles fine with just "rustc macro_test.rs"
#![feature(macro_rules)]
macro_rules! early_return(
($inp:expr, $($sp:ident),+) => (
match $inp {
$(
$sp(x) => { return x; }
)+
_ => {}
}
);
)
fn main() {
let n : Result<uint, ()> = Err(());
early_return!(n, Err);
println!("Got {}!", n.unwrap());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment