title: Is there a way to get the field names of a struct in a macro?
body: <p>Consider the following example:</p>
  
  <pre><code>struct S {
      a: String,
      b: String,
  }
  </code></pre>
  
  <p>I have a macro which is called like this:</p>
  
  <pre><code>my_macro!(S);
  </code></pre>
  
  <p>I want to access the field names of the struct in the macro like this:</p>
  
  <pre><code>macro_rules! my_macro {
      ($t:ty) =&gt; {{
          let field_names = get_field_names($t);
          // do something with field_names
      }};
  }
  </code></pre>
  
  <p>I'm new to Rust and macros, so maybe I'm missing something obvious.</p>