rust/src/test/run-pass/macro-interpolation.rs
2012-08-06 15:36:30 -07:00

19 lines
454 B
Rust

macro_rules! overly_complicated {
{$fnname:ident, $arg:ident, $ty:ty, $body:block, $val:expr, $pat:pat, $res:path} =>
{
fn $fnname($arg: $ty) -> option<$ty> $body
match $fnname($val) {
some($pat) => {
$res
}
_ => { fail; }
}
}
}
fn main() {
assert overly_complicated!(f, x, option<uint>, { return some(x); },
some(8u), some(y), y) == 8u
}