pub fn components(path: &Path) -> impl Iterator<Item = Component<'_>>
Expand description
Like Path::components()
, but produces an extra empty component at the end
when path
contains a trailing slash.
Example:
use nu_path::components;
let path = Path::new("/foo/bar/");
let mut components = components(path);
assert_eq!(components.next(), Some(Component::RootDir));
assert_eq!(components.next(), Some(Component::Normal(OsStr::new("foo"))));
assert_eq!(components.next(), Some(Component::Normal(OsStr::new("bar"))));
assert_eq!(components.next(), Some(Component::Normal(OsStr::new(""))));
assert_eq!(components.next(), None);