file extension
examples/path/extension/src/main.rs
fn main() { for path in [ "hello.rs", ".hello.swp", "hello.and.swp", ".github", ".bashrc", "dotless", ] { let path = std::path::Path::new(path); match path.extension() { Some(extension) => println!("{:15} {:?}", path.display(), extension), None => println!("{:15} None", path.display()), } } }
hello.rs "rs" .hello.swp "swp" hello.and.swp "swp" .github None .bashrc None dotless None