-
Notifications
You must be signed in to change notification settings - Fork 13k
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
RangeFrom iterator overflows when it gets to the maximum value of the type #25696
Comments
Would that change be backwards compatible? Arguably not, since it changes observable behavior in stable code, and although nobody should be relying on it, you never know. (For the record, I agree this is surprising, probably wrong, behavior. For example, iterating over |
CC @nrc (who probably has the best memory on this precise decision) |
This is the intentional behaviour. The expectation is that you will only use such iterators along with |
So if you have
(0u8..)
and iterate over it, it will keep going forever (in a release build anyway), producing 0, 1, 2, ... 255, 0, 1, 2, ...That is unexpected. It also panics in a debug build, so I assume it's also not intentional. I propose that instead of overflowing, the iterator instead returns
None
.The text was updated successfully, but these errors were encountered: