Skip to content
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

Missing impl<'a> PartialEq<&'a str> for OsString #49854

Closed
Kixunil opened this issue Apr 10, 2018 · 2 comments · Fixed by #51178
Closed

Missing impl<'a> PartialEq<&'a str> for OsString #49854

Kixunil opened this issue Apr 10, 2018 · 2 comments · Fixed by #51178
Labels
C-feature-accepted Category: A feature request that has been accepted pending implementation. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@Kixunil
Copy link
Contributor

Kixunil commented Apr 10, 2018

I've just got very surprised to find out that my_os_string == "foo" doesn't compile, but my_os_string == *"foo" does. After some investigation, I found that impl<'a> PartialEq<&'a str> for OsString is missing. Similar impl is present for String though.

I believe it'd be nice to implement it.

@pietroalbini pietroalbini added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Apr 11, 2018
@csmoe
Copy link
Member

csmoe commented Apr 13, 2018

&OsStr is to OsString as &str is to String, so check out impl<'a, 'b> PartialEq<&'a OsStr> for OsString, this implementation might meet your needs.

@Kixunil
Copy link
Contributor Author

Kixunil commented Apr 19, 2018

@csmoe I've soled my problem immediately. I filed issue because I think we could help others by implementing the trait.

@Mark-Simulacrum Mark-Simulacrum added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. C-feature-accepted Category: A feature request that has been accepted pending implementation. and removed C-feature-request Category: A feature request, i.e: not implemented / a PR. labels May 27, 2018
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jun 30, 2018
…onSapin

Implement PartialEq between &str and OsString

This fixes rust-lang#49854.

It allows equality comparison between `OsString` values and `str` references, such as `os_string == "something"`.
bors added a commit that referenced this issue Jun 30, 2018
Implement PartialEq between &str and OsString

This fixes #49854.

It allows equality comparison between `OsString` values and `str` references, such as `os_string == "something"`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-accepted Category: A feature request that has been accepted pending implementation. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants