title: How do I write a wrapper for a macro without repeating the rules?
body: <p>I am trying to make a wrapper for a macro. The trouble is that I don't want to repeat the same rules in both macro. Is there a way to do that?</p>
  
  <p>Here is what I tried:</p>
  
  <pre><code>macro_rules! inner {
      ($test:ident) =&gt; { stringify!($test) };
      ($test:ident.run()) =&gt; { format!("{}.run()", stringify!($test)) };
  }
  
  macro_rules! outer {
      ($expression:expr) =&gt; {
          println!("{}", inner!($expression));
      }
  }
  
  fn main() {
      println!("{}", inner!(test));
      println!("{}", inner!(test.run()));
      outer!(test);
      outer!(test.run());
  }
  </code></pre>
  
  <p>but I get the following error:</p>
  
  <pre><code>src/main.rs:8:31: 8:42 error: expected ident, found test
  src/main.rs:8         println!("{}", inner!($expression));
                                              ^~~~~~~~~~~
  </code></pre>
  
  <p>If I change the <code>outer</code> macro for this, the code compile:</p>
  
  <pre><code>macro_rules! outer {
      ($expression:expr) =&gt; {
          println!("{}", stringify!($expression));
      }
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>