-
Notifications
You must be signed in to change notification settings - Fork 21
ACP: Implement PartialEq<str>
for Path
, PathBuf
and vice-versa
#151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
Comments
Seconded, please send a PR. |
Kixunil
added a commit
to Kixunil/rust
that referenced
this issue
Jan 2, 2023
Comparison of paths and strings is expected to be possible and needed e.g. in tests. This change adds the impls os `PartialEq` between strings and paths, both owned and unsized, in both directions. ACP: rust-lang/libs-team#151
Kixunil
added a commit
to Kixunil/rust
that referenced
this issue
May 13, 2025
Comparison of paths and strings is expected to be possible and needed e.g. in tests. This change adds the impls os `PartialEq` between strings and paths, both owned and unsized, in both directions. ACP: rust-lang/libs-team#151
Kixunil
added a commit
to Kixunil/rust
that referenced
this issue
May 13, 2025
Comparison of paths and strings is expected to be possible and needed e.g. in tests. This change adds the impls os `PartialEq` between strings and paths, both owned and unsized, in both directions. ACP: rust-lang/libs-team#151
Kixunil
added a commit
to Kixunil/rust
that referenced
this issue
May 13, 2025
Comparison of paths and strings is expected to be possible and needed e.g. in tests. This change adds the impls os `PartialEq` between strings and paths, both owned and unsized, in both directions. ACP: rust-lang/libs-team#151
Kixunil
added a commit
to Kixunil/rust
that referenced
this issue
May 13, 2025
Comparison of paths and strings is expected to be possible and needed e.g. in tests. This change adds the impls os `PartialEq` between strings and paths, both owned and unsized, in both directions. ACP: rust-lang/libs-team#151
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
May 18, 2025
… r=<try> `impl PartialEq<{str,String}> for {Path,PathBuf}` This is a revival of rust-lang#105877 Comparison of paths and strings is expected to be possible and needed e.g. in tests. This change adds the impls os `PartialEq` between strings and paths, both owned and unsized, in both directions. ACP: rust-lang/libs-team#151
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
Proposal
Problem statement
When testing functions that return
PathBuf
one might want to useassert_eq!
with a string literal in tests. This is currently impossible because of lacking impls.Motivation, use-cases
For my use case, the function in question processes program arguments assuming zeroth argument is the path to the program, so it returns
PathBuf
which should be the most appropriate. In the test I mock the arguments providing a different iterator with known zeroth argument. I wish to compare them to ensure the function returns the correct value.I would be surprised if there weren't any other tested existing crates that do some path computation.
Solution sketches
I believe this is the obvious, idiomatic solution. I don't see any meaningful downsides.
Links and related work
N/A, will send a PR if this is approved.
What happens now?
This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.
The text was updated successfully, but these errors were encountered: