-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Fix range sugar #20500
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
Fix range sugar #20500
Conversation
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
cc @nick29581, what's the intention of the |
Thanks @globin for fixing this! |
No, this is not right - the Option is None if for the case where it is impractical or impossible to calculate the size hint, e.g., for open ranges, or ranges over data types where calculating the difference is expensive or impossible. So, this patch should just switch the params (the history there is the method used to be called difference or something, where it made sense to have the larger thing first) and continue with the debug_assert. |
Perhaps And surely |
dfa9ca9
to
0a9a66d
Compare
I've just updated with new param names and the |
Is |
0a9a66d
to
5cc1738
Compare
Yeah, I think start == end is fine |
Fix range sugar Reviewed-by: nick29581
Range sugar was using the trait incorrectly plus the trait implementation was wrong.
Both had the arguments swapped which actually caused the tests to run but threw the debug_assert
in debug builds, causing normal builds of anything using the sugar to fail.