-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Implement PartialEq<[A]>
for VecDeque<A>
.
#38661
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aturon (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
e4224fd
to
5e5e1f6
Compare
PartialEq<&[A]>
for VecDeque
.PartialEq<&[A]>
for VecDeque<A>
.
@@ -2158,6 +2158,18 @@ impl<A: PartialEq> PartialEq for VecDeque<A> { | |||
#[stable(feature = "rust1", since = "1.0.0")] | |||
impl<A: Eq> Eq for VecDeque<A> {} | |||
|
|||
#[stable(feature = "vec-deque-partial-eq-slice", since = "")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder for future self that since
should be filled in.
A crater run might be good for this (see this comment for more information). |
@@ -2158,6 +2158,18 @@ impl<A: PartialEq> PartialEq for VecDeque<A> { | |||
#[stable(feature = "rust1", since = "1.0.0")] | |||
impl<A: Eq> Eq for VecDeque<A> {} | |||
|
|||
#[stable(feature = "vec-deque-partial-eq-slice", since = "")] | |||
impl<'a, A: PartialEq> PartialEq<&'a [A]> for VecDeque<A> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the correct signature? Should it be PartialEq<[A]>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think PartialEq<[A]>
should be the primary one. Does that change the utility of it? The type inference problems? (I guess it's the same.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can change it to impl<A: PartialEq> PartialEq<[A]> for VecDeque<A>
and the non-test code compiles.
But if one does:
let mut d = VecDeque::new();
d.push_back('a');
d.push_back('b');
let v = vec!['a', 'b'];
assert!(d == &v);
...which looks perfectly valid to me, this compile error appears:
error[E0277]: the trait bound `collections::VecDeque<char>: std::cmp::PartialEq<&collections::vec::Vec<char>>` is not satisfied
--> src/libcollections/../libcollectionstest/vec_deque.rs:623:13
|
623 | assert!(d == &v);
| ^^^^^^^ the trait `std::cmp::PartialEq<&collections::vec::Vec<char>>` is not implemented for `collections::VecDeque<char>`
|
= help: the following implementations were found:
= help: <collections::VecDeque<A> as std::cmp::PartialEq>
= help: <collections::VecDeque<A> as std::cmp::PartialEq<[A]>>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like one would have to write assert!(d == *&v[..]);
, which seems less than ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v[..]
must be enough. Still, less than ideal, but not surprising, since it's generic and thus &v
can't coerce to anything anyway, it would need an explicit impl for &Vec<_>
, would it not, to have d == &v
compile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in the latest commit.
PartialEq<&[A]>
for VecDeque<A>
.PartialEq<[A]>
for VecDeque<A>
.
cc @rust-lang/libs, this would be instantly stable. |
@brson, can you do a crater run? In general, I'm 👍 on this addition. |
LGTM assuming the whole world doesn't break, which I don't imagine it will. |
@aturon wanna fcp merge this? Otherwise lgtm |
@rfcbot fcp merge (We'll wait for crater before actually merging.) |
Team member @aturon has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
To double check, I thought |
79566a1
to
5458a1f
Compare
Added more |
☔ The latest upstream changes (presumably #38581) made this pull request unmergeable. Please resolve the merge conflicts. |
5458a1f
to
61313c1
Compare
Rebased. |
Yes I can crater. |
|
I don't really understand the taskcluster interface. Did everything pass? |
🔔 This is now entering its final comment period, as per the review above. 🔔 psst @aturon, I wasn't able to add the |
There's no discussion here, just me claiming different things about how I expected it to be and how Vec does it. What Vec does is obviously a mess (So many impls), do we really want to continue that? With so many impls, it's very hard to remember when exactly a thing like |
Crater says one false positive. |
Sooooo is this good to go? Should I fill in |
@frewsxcv Let's do it! |
61313c1
to
b081872
Compare
This should be good to go! |
@bors: r+ |
📌 Commit b081872 has been approved by |
Implement `PartialEq<[A]>` for `VecDeque<A>`. Fixes #38625.
💔 Test failed - status-travis |
@bors retry |
⌛ Testing commit b081872 with merge 6f923bf... |
💔 Test failed - status-appveyor |
@bors retry couldn't fetch cargo |
⌛ Testing commit b081872 with merge 4c357d0... |
💔 Test failed - status-travis |
@bors: retry
…On Wed, Feb 1, 2017 at 5:40 AM, bors ***@***.***> wrote:
💔 Test failed - status-travis
<https://travis-ci.org/rust-lang/rust/builds/197288644>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#38661 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAD95GU-Sb8fqkeXk1XAfDWuMp8y1ztcks5rYIs4gaJpZM4LXKey>
.
|
⌛ Testing commit b081872 with merge 123afbd... |
💔 Test failed - status-appveyor |
… On Wed, Feb 1, 2017 at 4:27 PM, bors ***@***.***> wrote:
💔 Test failed - status-appveyor
<https://ci.appveyor.com/project/rust-lang/rust/build/1.0.1780>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#38661 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAD95MFGrhQHdzwZHvQ26-OjqCUYNmJyks5rYSLlgaJpZM4LXKey>
.
|
Implement `PartialEq<[A]>` for `VecDeque<A>`. Fixes #38625.
☀️ Test successful - status-appveyor, status-travis |
Fixes #38625.