Open
Description
Location
https://doc.rust-lang.org/nightly/std/env/fn.split_paths.html
Summary
The iterator returned by std::env::split_paths
yields a single empty empty string when given a ""
or OsStr::new("")
argument. Is this by design or a bug?
I found it unexpected that an empty path string yielded any paths at all and was curious if this is a quirk of the implementation using slice::Split
on the internals.
use std::env::split_paths;
fn main() {
println!("{:?}", split_paths("").collect::<Vec<_>>());
println!("{:?}", split_paths(":").collect::<Vec<_>>());
println!("{:?}", split_paths("::").collect::<Vec<_>>());
}
outputs:
[""]
["", ""]
["", "", ""]
The second and third output make sense to me. In the absence of documented behavior, I'm not sure about the first one.
If this is the expected behavior, can it be added to the documentation?