title: How do I replace the file extension of a PathBuf or Path?
body: <p>My current solution is:</p>
  <pre><code>let temp = format!(
      &quot;{}.png&quot;,
      path.file_stem().unwrap().to_string_lossy());
  path.pop();
  path.push(&amp;temp);
  </code></pre>
  <p>Which is quite ugly, requiring at least 6 function calls and creating an new string.</p>
  <p>Is there a more idiomatic, shorter, or more efficient way to do this?</p>