Declarative macro : no more then 2 expressions?

Can anyone explain why macro works for 2 expressions, but does not for 3?

  print!( 1, 2 ); // <- that works
  print!( 1, 2, 3 ); // <- this does not

Playground

You missed the $ before Arg3. This works.

2 Likes

Oh mine..

The rule

    ($Arg1 : expr, $Arg2 : expr, Arg3 : expr) => {
        println!("{} {} {}", $Arg1, $Arg2, $Arg3);
    };

matches <any expr>, <any expr>, Arg3, literally. You probably meant to use $Arg3 in the rule, not Arg3.

2 Likes

You are right. Thanks!

<any expr>, <any expr>, Arg3 : expr

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.