-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Implement useful steps_between for all integers #59444
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
r? @kennytm (rust_highfive has picked a reviewer for you, use r? to override) |
We can use `usize::try_from` to convert steps from any size of integer. This enables a meaningful `size_hint()` for larger ranges, rather than always just `(0, None)`. Now they return the true `(len, Some(len))` when it fits, otherwise `(usize::MAX, None)` for overflow.
r? @scottmcm |
Note, this former behavior meant that a lot of the |
Ping from triage, @scottmcm :) |
📌 Commit a548d83 has been approved by |
Implement useful steps_between for all integers We can use `usize::try_from` to convert steps from any size of integer. This enables a meaningful `size_hint()` for larger ranges, rather than always just `(0, None)`. Now they return the true `(len, Some(len))` when it fits, otherwise `(usize::MAX, None)` for overflow.
Rollup of 8 pull requests Successful merges: - #59262 (Remove duplicated code from Iterator::{ne, lt, le, gt, ge}) - #59286 (Refactor async fn return type lowering) - #59444 (Implement useful steps_between for all integers) - #59452 (Speed up rustdoc run a bit) - #59533 (Support allocating iterators with arenas) - #59585 (Fixes for shallow borrows) - #59607 (Renames `EvalErrorKind` to `InterpError`) - #59613 (SGX target: convert a bunch of panics to aborts) Failed merges: - #59630 (Shrink `mir::Statement`.) r? @ghost
@scottmcm great, thanks for the added background! |
We can use
usize::try_from
to convert steps from any size of integer.This enables a meaningful
size_hint()
for larger ranges, rather thanalways just
(0, None)
. Now they return the true(len, Some(len))
when it fits, otherwise
(usize::MAX, None)
for overflow.