Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Get A Filename From A Path In Rust

rust
use std::path::PathBuf;

fn main() {

  let path = PathBuf::from("/Users/alan/Desktop/here.txt");
  println!("{}", path.file_name().unwrap().to_str().unwrap());

}

This goes through [TODO: Code shorthand span ] which is why there are two unwraps.