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
impl PartialEq<Option<&OsStr>> for Option<&str> #74369
Conversation
Allows `path.extension() == Some("ext")` Long alternative `path.extension().map_or(false, |ext| ext == "ext")` I wish `if let Some("ext") = path.extension()` works too
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
This seems oddly specific. Perhaps we should implement |
Ah, that does seem possible. I thought about that but I am not sure if that's useful. Should I change it? |
It's definitely useful in more situations :) |
It doesn't seemed to work though. |
That's because the manually-implemented |
Ah, I didn't know that. Let me check again. |
@NieDzejkob It seemed to be breaking chance to do that. impl<T, U> PartialEq<Op<T>> for Op<U>
where
T: PartialEq<U>,
U: PartialEq<T>,
{
#[inline]
fn eq(&self, other: &Op<T>) -> bool {
self.as_ref()
.zip(other.as_ref())
.map_or(false, |(x, y)| x == y)
}
}
#[test]
fn derive_partialeq() {
use std::ffi::OsStr;
assert_eq!(Op::Some("a"), Op::Some("a"));
assert_eq!(Op::Some("a"), Op::Some(OsStr::new("a")));
// assert_ne!(Op::Some("a"), Op::None); // does not compile
assert_ne!(Op::Some("a"), Op::None::<&str>);
} |
Hmm, I'm out of my depth here, but perhaps there is a special feature that could be used to disambiguate this. |
☔ The latest upstream changes (presumably #73265) made this pull request unmergeable. Please resolve the merge conflicts. |
@pickfire Ping from triage: can you please address the merge conflict and build failures? |
@JohnCSimon No, I will be creating a new patch for this in another pull request. |
The build breaks because I cannot impl for |
@crlf0710 I need help on this, I don't know how to fix it. |
I don't think this is implementable without the breaking change pointed out in #74369 (comment) |
So I need to close this? |
IIRC unfortunately i don't think this is currently possible without IIRC |
Closing this based on the above comments. If you have a better way to do this you can submit a new PR :) |
Allows
path.extension() == Some("ext")
Long alternative
path.extension().map_or(false, |ext| ext == "ext")
I wish
if let Some("ext") = path.extension()
works too