title: Whats the most direct way to convert a Path to a *c_char?
body: <p>Given a <code>std::path::Path</code>, what's the most direct way to convert this to a null-terminated <code>std::os::raw::c_char</code>? (for passing to C functions that take a path).</p>
  
  <pre><code>use std::ffi::CString;
  use std::os::raw::c_char;
  use std::os::raw::c_void;
  
  extern "C" {
      some_c_function(path: *const c_char);
  }
  
  fn example_c_wrapper(path: std::path::Path) {
      let path_str_c = CString::new(path.as_os_str().to_str().unwrap()).unwrap();
  
      some_c_function(path_str_c.as_ptr());
  }
  </code></pre>
  
  <p>Is there a way to avoid having so many intermediate steps?</p>
  
  <pre class="lang-none prettyprint-override"><code>Path -&gt; OsStr -&gt; &amp;str -&gt; CString -&gt; as_ptr()
  </code></pre>