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 OsStr which is why there are two unwraps.
OsStr