title: How to get the size of a struct field in Rust without instantiating it
body: <p>I have a structure with a byte array in it. This structure actually comes from the FFI bindings produced by bindgen, and its size is defined in C code using a macro, i.e.:</p>
  
  <p>C code:</p>
  
  <pre class="lang-c prettyprint-override"><code>#define FOO_SIZE 100
  
  struct the_struct
  {
      char foo[FOO_SIZE];
      /* other fields... */
  };
  </code></pre>
  
  <p>Generated FFI bindings:</p>
  
  <pre class="lang-rust prettyprint-override"><code>pub struct the_struct {
      pub foo: [::std::os::raw::c_char; 100usize],
      // other fields...
  }
  </code></pre>
  
  <p>I want to make sure that the data coming from the Rust API side fits into <code>foo</code>. I also do not want to hard code <code>FOO_SIZE</code> in my Rust API, since it is subject to change.</p>
  
  <p>I understand that this can be done by instantiating the struct first, but then again, that would require explicit initialization of <code>foo</code>, which seems to be impossible without knowing its size. Furthermore, it is an extra step I want to avoid.</p>
  
  <p>Is it possible to somehow get the size of <code>foo</code> statically without instantiating the structure? If not, what would be the best approach? Changing C code is not an option.</p>