-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Open
Labels
A-strArea: str and StringArea: str and StringC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.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
Given that &OsStr
is comparable to &str
, I would expect &Path
(and PathBuf
) to be comparable to &str
since &OsStr
and &Path
can freely convert to each other.
Example
use std::path::{Path, PathBuf};
fn main() {
let path = PathBuf::from("-");
println!("{}", path == Path::new("-"));
println!("{}", path.as_os_str() == Path::new("-"));
println!("{}", path.as_os_str() == "-");
println!("{}", path == "-");
let path = Path::new("-");
println!("{}", path == PathBuf::from("-"));
println!("{}", path.as_os_str() == Path::new("-"));
println!("{}", path.as_os_str() == "-");
println!("{}", path == "-");
}
Playground
Metadata
Metadata
Assignees
Labels
A-strArea: str and StringArea: str and StringC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.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.