/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. fn main() {
  3. #macro[[#mylambda[x, body],
  4. {
  5. fn f(x: int) -> int { return body; }
  6. f
  7. }]];
  8. assert (mylambda!{y, y * 2}(8) == 16);
  9. macro_rules! mylambda_tt{
  10. {$x:ident, $body:expr} => {
  11. fn f($x: int) -> int { return $body; };
  12. f
  13. }
  14. }
  15. assert(mylambda_tt!{y, y * 2}(8) == 16)
  16. }