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.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=a57d0e83edebdcbe70e5e2a54424ee9f
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?
Location
https://doc.rust-lang.org/nightly/std/env/fn.split_paths.html
Summary
The iterator returned by
std::env::split_pathsyields a single empty empty string when given a""orOsStr::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::Spliton the internals.https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=a57d0e83edebdcbe70e5e2a54424ee9f
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?