PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/run-pass/macro-2.rs

http://github.com/jruderman/rust
Rust | 20 lines | 15 code | 4 blank | 1 comment | 2 complexity | 64526cf652ccbc2ec79562f9a311ee4f MD5 | raw file
 1// xfail-pretty - token trees can't pretty print
 2
 3fn main() {
 4    #macro[[#mylambda[x, body],
 5            {
 6                fn f(x: int) -> int { return body; }
 7                f
 8            }]];
 9
10    assert (mylambda!{y, y * 2}(8) == 16);
11
12    macro_rules! mylambda_tt{
13        {$x:ident, $body:expr} => {
14            fn f($x: int) -> int { return $body; };
15            f
16        }
17    }
18
19    assert(mylambda_tt!{y, y * 2}(8) == 16)
20}