std-method
Path::file_name: last name component
Extract a final normal name component if present. Handle absent names and native text separately. Expected stdout (not executed): report.csv Common mistake: Taking a substring after a hard-coded separator.
Formal Syntax & Structure
rust syntaxrust
path.file_name() -> Option<&OsStr>Working Example
Example Snippetrust
fn main() { use std::path::Path; let p = Path::new("archive/report.csv"); println!("{}", p.file_name().unwrap().to_str().unwrap());}