directory ancestors (parent directories)
-
ancestors
use std::path::Path; fn main() { let path = Path::new("one/two/three/four.rs"); println!("{}", path.display()); for p in path.ancestors() { println!("{}", p.display()); } }
one/two/three/four.rs
one/two/three/four.rs
one/two/three
one/two
one