std-type
Path: borrowed filesystem name
Borrow a path without opening a file. Unlike a string, a path uses the operating system representation and may not be valid UTF-8. Expected stdout (not executed): txt Common mistake: Assuming all native filenames can be converted to UTF-8.
Formal Syntax & Structure
rust syntaxrust
Path::new(s: &S) -> &PathWorking Example
Example Snippetrust
fn main() { use std::path::Path; let p = Path::new("notes.txt"); println!("{}", p.extension().unwrap().to_str().unwrap());}