directory ancestors (parent directories)



examples/path/ancestors/src/main.rs
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