-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
RangeInclusive<usize> shouldn't impl ExactSizeIterator #36386
Comments
As I mention in a followup comment in reddit, I think that Penalizing I think that the right thing to do is to still panic, but do so earlier, on construction. Arguably, if somebody wants to do |
Panic on construction is icky. RangeInclusive is supposed to be useful as an argument type (it's more than an iterator). I think this PR is fine (it's unstable and we can add it back). A change in the trait's contract could enable range inclusive to keep the implementation: #34433 (comment) ? I don't think it's too crazy, warrants discussion. |
As long as we somehow manage to keep |
I somewhat agree that it's lame for the whole type to be I'm not sure about @bluss's "saturating |
If we use the same logic as we do for the Similarly as pointed out #34433 (comment) we shouldn't have implementations of |
Well it is already implemented for It seems that this decision has not been made as different parts of the standard library are following different guidelines (the |
I personally think it would be fine to have impls gated on the size of Either way we'll need to remove the |
I updated the PR to remove those. Perhaps I could put them back gated by |
I realized ESI was introduced to support the .rposition() (index from the back) method, which will then return the wrong result for too long chains. Not that such a big index is that useful, but it would still be wrong with the saturating ESI contract. |
See rust-lang/rfcs#1748. |
remove ExactSizeIterator from RangeInclusive<{u,i}{32,size}> Fixes #36386. This is a [breaking-change] for nightly users of `#![feature(inclusive_range_syntax)]` and/or `#![feature(inclusive_range)]`.
(0...usize::max_value()).len()
panics:cc @gnzlbg https://www.reddit.com/r/rust/comments/51mlth/how_should_we_represent_ranges_in_the_standard/d7gdx1v
The text was updated successfully, but these errors were encountered: