rust/src/test/run-pass/macro-interpolation.rs
2012-08-26 15:56:16 -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
}