Add IntoIterator impl for arrays by value (for [T; N]) - #65819
Closed
LukasKalbertodt wants to merge 4 commits into
Closed
Add IntoIterator impl for arrays by value (for [T; N])#65819LukasKalbertodt wants to merge 4 commits into
IntoIterator impl for arrays by value (for [T; N])#65819LukasKalbertodt wants to merge 4 commits into
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current status (2020-12-30):
Const generics are stable now, so this PR is unblocked. The main remaining question is how to deal with the regressions caused by this change (see this comment). In the meantime, you can use
IntoIterator::newwhich has been stabilized independently.Status update comments:
IntoIteratorimpl for arrays by value (for [T; N]) #65819 (comment)IntoIteratorimpl for arrays by value (for [T; N]) #65819 (comment)IntoIteratorimpl for arrays by value (for [T; N]) #65819 (comment)Closes #25725
Initially part of #62959, this PR adds this impl:
TODO
array.into_iter()#66017)The backwards compatibility problem
Adding this impl is not as straight-forward as it seems: there are some backwards compatibility hazards. In particular, due to autoref, this compiles today:
With this change, that code wouldn't compile anymore, as
xinside the loop would have the typebooland not&bool(like it does today). One should note that this only happens when using the.methodcall syntax with.into_iter(). It does not affect.iter()(different method) and it does not affect thefor-loop syntax (does not involve autoref).There has been some discussion in #49000 and in #62959. Most agree that a crater run would be very useful. That's what this PR is for.
But the fact that this change didn't break anything in the compiler is already promising.(it did)Arguments to add this
impldespite the potential breakage:.into_iter(), as.iter()is shorter and theforloop desugars tointo_iter()anyway.So hopefully no one used this in the real world.(people did use that in the real world)CC @Centril @Mark-Simulacrum @cuviper