title: What's the correct way to convert from &str to OsStr?
body: <p>I'm working with <a href="https://github.com/zargony/rust-fuse" rel="noreferrer">rust-fuse</a>, which takes mount options as a <code>&amp;[&amp;std::ffi::os_str::OsStr]</code>. It appears that I should be splitting my incoming comma-separated options string, which I'm doing like so:</p>
  
  <pre><code>mod fuse {
      use std::ffi::OsStr;
  
      pub fn mount(options: &amp;[&amp;OsStr]) {}
  }
  
  fn example(optstr: &amp;str) {
      let mut options: &amp;[&amp;str] = &amp;[];
      if optstr != "" {
          options = optstr.split(",").collect::&lt;Vec&lt;_&gt;&gt;().as_slice();
      }
      fuse::mount(options)
  }
  </code></pre>
  
  <p>Which gives the following error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0308]: mismatched types
    --&gt; src/main.rs:12:17
     |
  12 |     fuse::mount(options)
     |                 ^^^^^^^ expected struct `std::ffi::OsStr`, found str
     |
     = note: expected type `&amp;[&amp;std::ffi::OsStr]`
                found type `&amp;[&amp;str]`
  </code></pre>
  
  <p>I was under the impression that all <code>&amp;str</code>s were also <code>OsStr</code>s, but I'm new to Rust, so I guess that's wrong. </p>