2012-07-11 12:42:59 -05:00
|
|
|
// xfail-pretty - token trees can't pretty print
|
|
|
|
|
2011-06-27 12:58:05 -05:00
|
|
|
fn main() {
|
2011-08-19 17:16:48 -05:00
|
|
|
#macro[[#mylambda[x, body],
|
|
|
|
{
|
2012-08-01 19:30:05 -05:00
|
|
|
fn f(x: int) -> int { return body; }
|
2011-08-19 17:16:48 -05:00
|
|
|
f
|
|
|
|
}]];
|
2011-07-13 17:44:09 -05:00
|
|
|
|
2012-08-22 19:24:52 -05:00
|
|
|
assert (mylambda!(y, y * 2)(8) == 16);
|
2012-07-11 12:42:59 -05:00
|
|
|
|
2012-08-22 19:47:11 -05:00
|
|
|
macro_rules! mylambda_tt(
|
2012-08-22 20:06:54 -05:00
|
|
|
($x:ident, $body:expr) => {
|
2012-08-01 19:30:05 -05:00
|
|
|
fn f($x: int) -> int { return $body; };
|
2012-07-11 12:42:59 -05:00
|
|
|
f
|
|
|
|
}
|
2012-08-22 19:47:11 -05:00
|
|
|
)
|
2012-07-11 12:42:59 -05:00
|
|
|
|
2012-08-22 19:24:52 -05:00
|
|
|
assert(mylambda_tt!(y, y * 2)(8) == 16)
|
2011-08-19 17:16:48 -05:00
|
|
|
}
|