title: How to get the name of current program without the directory part?
body: <p>In Bash this would be <code>${0##*/}</code>.</p>
  
  <pre><code>use std::env;
  use std::path::Path;
  
  fn prog() -&gt; String {
      let prog = env::args().next().unwrap();
      String::from(Path::new(&amp;prog).file_name().unwrap().to_str().unwrap())
  }
  
  fn main() {
      println!("{}", prog());
  }
  </code></pre>
  
  <p>Is there a better way? (I particularly dislike those numerous <code>unwrap()</code>s.)</p>