title: Pass 2D array of bytes to C in Rust
body: <p>I've written a function in C with this signature:</p>
  <pre><code>write_stuff(char **pages, uint32 page_count);
  </code></pre>
  <p><code>pages</code> will be an array of 128 elements, with each element either NULL or pointing to a char array of 8192 bytes. So, an array of arrays with fixed, known sizes.</p>
  <p>I need to populate the arrays in Rust and pass them to the C function. When I generate a Rust signature using bindgen, it produces this:</p>
  <pre><code>extern &quot;C&quot; {
      pub fn write_stuff(pages: *mut *mut ::std::os::raw::c_char, page_count: u32,);
  }
  </code></pre>
  <p>Now, how do I declare a variable in Rust that I can populate and pass to this function?</p>
  <p>I tried this:</p>
  <pre><code>let mut pages = [Option &lt;[u8; 8192]&gt;; 128];
  </code></pre>
  <p>but it doesn't compile.</p>
  <p>This does compile:</p>
  <pre><code>type MyPage = Option&lt;[u8; 8192]&gt;;
  let myarray: [MyPage; 128] = [None; 128];
  </code></pre>
  <p>but I'm not clear on whether it would store the data in the right format, or how to cast it appropriately:</p>
  <pre><code>let pages: *mut *mut ::std::os::raw::c_char = myarray.as_mut_ptr() as // what goes here?;
  </code></pre>