title: How do I generalize a Rust macro over different types of functions?
body: <p>I have a macro that takes a list of function declarations and turns them into different declarations.</p>
  
  <pre><code>macro_rules! re_export {
      ($(pub fn $i:ident($($arg:ident: $argty:ty)*) -&gt; $ret:ty;)*) =&gt; ($(
          extern {
              pub fn $i($($arg: $argty),*) -&gt; $ret;
          }
      )*);
      ($(pub fn $i:ident($($arg:ident: $argty:ty)*);)*) =&gt; ($(
          extern {
              pub fn $i($($arg: $argty),*);
          }
      )*);
  }
  </code></pre>
  
  <p>Which is used like this:</p>
  
  <pre><code>re_export! {
      pub fn abs(i: c_int) -&gt; c_int;
      pub fn rand() -&gt; c_int;
      pub fn foo();
      pub fn add(i: c_int, j: c_int) -&gt; c_int;
  }
  </code></pre>
  
  <p>How can I generalize the macro so that I can give it multiple functions with or without args and return types and have it work on all of them. It's easy to make a macro that works on several functions of the same type, but I can't figure out how to make it work for different types.</p>