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

assertEmpty(WindowsPath().parents);
assertEmpty(WindowsPath(".").parents);
assertEmpty(WindowsPath("foo.txt").parents);
assertEqual(WindowsPath("C:/hello/world").parents, [ WindowsPath(`C:\hello`), WindowsPath(`C:\`) ]);
assertEqual(WindowsPath("C:/hello/world/").parents, [ WindowsPath(`C:\hello`), WindowsPath(`C:\`) ]);

assertEmpty(PosixPath().parents);
assertEmpty(PosixPath(".").parents);
assertEmpty(PosixPath("foo.txt").parents);
assertEqual(PosixPath("/hello/world").parents, [ PosixPath("/hello"), PosixPath("/") ]);
assertEqual(PosixPath("/hello/world/").parents, [ PosixPath("/hello"), PosixPath("/") ]);

Meta