parent_iter

Function parent_iter 

Source
pub fn parent_iter(path: &Path) -> impl DoubleEndedIterator<Item = &Path>
Expand description

Produces an iterator iterating over all parent directories, exclusive of path.

§Arguments

path: The current path.

§Example

use std::path::Path;
use virtual_filesystem::util::parent_iter;

itertools::assert_equal(
    parent_iter(Path::new("/many/files/and/directories")),
    vec![
        Path::new("/many/files/and"),
        Path::new("/many/files"),
        Path::new("/many"),
        Path::new("/"),
    ],
);

itertools::assert_equal(
    parent_iter(Path::new("../many/files/and/directories")),
    vec![
        Path::new("../many/files/and"),
        Path::new("../many/files"),
        Path::new("../many"),
        Path::new(".."),
    ],
);