-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Iterators in the std library should implement Eq where possible #12593
Comments
How would you define two iterators to be equal? |
It's not actually going to be able to increment the iterators, because |
@thestinger this is meant to be comparing the iterator state (where that makes sense), not the contents of the iterator. e.g. |
That makes sense, but it may be a bit surprising. The only other place using identity-based equality is the raw pointer implementation of |
@huonw Is it possible to compare two |
You can have two immutable iterators from one vector. @thestinger true enough that it might be confusing. |
(To be clear, by "immutable iterator" I mean the one yielding immutable references ( |
I don't think it makes sense to do this. The only real way to find out if two iterators are truly equal is to iterate through them. That's true even for the iterator returned by |
I disagree that adding an (That said, I agree that pointer-based equality does not seem like the right road to take here.) |
I suggested an RFC because I don't think people will agree with using shallow equality, but I can't speak for others. It can't really do anything but shallow equality since deep equality implies moving the iterator forwards. |
…Veykril fix: complete enum variants as patterns in pattern path close rust-lang#12593
[Per discussion with @huonw on
#rust
.]I've written a function
apply
like so:The idea is to parse the input and also return an iterator that's correctly advanced. I'm writing a test for this and Iterators not implementing Eq is making this more difficult than it needs to be.
The text was updated successfully, but these errors were encountered: