-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-processArea: `std::process` and `std::env`Area: `std::process` and `std::env`T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
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?
RReverser
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-processArea: `std::process` and `std::env`Area: `std::process` and `std::env`T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.