parents

/foo/bar/baz/hurr.durr => { Path("/foo/bar/baz"), Path("/foo/bar"), Path("/foo"), Path("/") }

parents
(
PathType
)
(
auto ref in PathType p
)
if (
isSomePath!PathType
)

Examples

1 assertEmpty(WindowsPath().parents);
2 assertEmpty(WindowsPath(".").parents);
3 assertEmpty(WindowsPath("foo.txt").parents);
4 assertEqual(WindowsPath("C:/hello/world").parents, [ WindowsPath(`C:\hello`), WindowsPath(`C:\`) ]);
5 assertEqual(WindowsPath("C:/hello/world/").parents, [ WindowsPath(`C:\hello`), WindowsPath(`C:\`) ]);
6 
7 assertEmpty(PosixPath().parents);
8 assertEmpty(PosixPath(".").parents);
9 assertEmpty(PosixPath("foo.txt").parents);
10 assertEqual(PosixPath("/hello/world").parents, [ PosixPath("/hello"), PosixPath("/") ]);
11 assertEqual(PosixPath("/hello/world/").parents, [ PosixPath("/hello"), PosixPath("/") ]);

Meta