title: Is there a way to avoid cloning when converting a PathBuf to a String?
body: <p>I need to simply (and dangerously - error handling omitted for brevity) get the current executable name. I made it work, but my function converts a <code>&amp;str</code> to <code>String</code> only to call <code>as_str()</code> on it later for pattern matching.</p>
  
  <pre><code>fn binary_name() -&gt; String {
      std::env::current_exe().unwrap().file_name().unwrap().to_str().unwrap().to_string()
  }
  </code></pre>
  
  <p>As I understand it, <code>std::env::current_exe()</code> gives me ownership of the <code>PathBuf</code> which I could transfer by returning it. As it stands, I borrow it to convert it to <code>&amp;str</code>. From there, the only way to return the string is to clone it before the <code>PathBuf</code> is dropped.</p>
  
  <p>Is there any way to avoid this <code>&amp;OsStr -&gt; &amp;str -&gt; String -&gt; &amp;str</code> cycle?</p>