title: How to programmatically get the number of fields of a struct?
body: <p>I have a custom struct like the following:</p>
  
  <pre><code>struct MyStruct {
      first_field: i32,
      second_field: String,
      third_field: u16,
  }
  </code></pre>
  
  <p>Is it possible to get the number of struct fields programmatically (like, for example, via a method call <code>field_count()</code>):</p>
  
  <pre><code>let my_struct = MyStruct::new(10, "second_field", 4);
  let field_count = my_struct.field_count(); // Expecting to get 3
  </code></pre>
  
  <p>For this struct:</p>
  
  <pre><code>struct MyStruct2 {
      first_field: i32,
  }
  </code></pre>
  
  <p>... the following call should return <code>1</code>:</p>
  
  <pre><code>let my_struct_2 = MyStruct2::new(7);
  let field_count = my_struct2.field_count(); // Expecting to get count 1
  </code></pre>
  
  <p>Is there any API like <code>field_count()</code> or is it only possible to get that via macros?</p>
  
  <p>If this is achievable with macros, how should it be implemented?</p>