-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Correct iterator adaptor Chain #27991
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
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
r? @gankro |
90e9de5
to
a5d6eaa
Compare
Could you add a comment to |
The iterator protocol specifies that the iteration ends with the return value `None` from `.next()` (or `.next_back()`) and it is unspecified what further calls return. The chain adaptor must account for this in its DoubleEndedIterator implementation. It uses three states: - Both `a` and `b` are valid - Only the Front iterator (`a`) is valid - Only the Back iterator (`b`) is valid The fourth state (neither iterator is valid) only occurs after Chain has returned None once, so we don't need to store this state. Fixes rust-lang#26316
Updated with a comment. If only one end of the iterator is used and everything is inlined, llvm should see that the state field only takes on two values (For example Both and Back), so it could behave like it did before. |
Correct iterator adaptor Chain The iterator protocol specifies that the iteration ends with the return value `None` from `.next()` (or `.next_back()`) and it is unspecified what further calls return. The chain adaptor must account for this in its DoubleEndedIterator implementation. It uses three states: - Both `a` and `b` are valid - Only the Front iterator (`a`) is valid - Only the Back iterator (`b`) is valid The fourth state (neither iterator is valid) only occurs after Chain has returned None once, so we don't need to store this state. Fixes #26316
Looks like one of the windows builders disappeared, but this passed tests everywhere (including windows) so merging manually. |
Thanks for the adjustment |
Correct iterator adaptor Chain
The iterator protocol specifies that the iteration ends with the return
value
None
from.next()
(or.next_back()
) and it is unspecifiedwhat further calls return. The chain adaptor must account for this in
its DoubleEndedIterator implementation.
It uses three states:
a
andb
are valida
) is validb
) is validThe fourth state (neither iterator is valid) only occurs after Chain has
returned None once, so we don't need to store this state.
Fixes #26316