-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Range<u64> implements ExactSizeIterator #22047
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
Comments
I checked the code and it turns out the impl is conditional -- only on 64-bit platforms. So that's correct and for me it turned into a different question of whether that kind of platform dependence is good. I've started a discussion about that here. |
Reopened, got some voices backing that this is a bug. Soft solution would be to warn on using that particular impl of ExactSizeIterator for Range and i64, but I don't know if we can even do that. Otherwise we can just remove the impls. |
Fixes rust-lang#22047 Range<u64> and Range<i64> may be longer than usize::MAX on 32-bit platforms, and thus they cannot fulfill the protocol for ExactSizeIterator. We don't want a nonobvious platform dependency in basic iterator traits, so the trait impl is removed. The logic of this change assumes that usize is at least 32-bit. This is technically a breaking change; note that Range<usize> and Range<isize> are always ExactSizeIterators. [breaking-change]
…=alexcrichton Fixes rust-lang#22047 Range<u64> and Range<i64> may be longer than usize::MAX on 32-bit platforms, and thus they cannot fulfill the protocol for ExactSizeIterator. We don't want a nonobvious platform dependency in basic iterator traits, so the trait impl is removed. The logic of this change assumes that usize is at least 32-bit. This is technically a breaking change; note that Range<usize> and Range<isize> are always ExactSizeIterators. [breaking-change]
…=alexcrichton Fixes rust-lang#22047 `Range<u64>` and `Range<i64>` may be longer than usize::MAX on 32-bit platforms, and thus they cannot fulfill the protocol for ExactSizeIterator. We don't want a nonobvious platform dependency in basic iterator traits, so the trait impl is removed. The logic of this change assumes that usize is at least 32-bit. This is technically a breaking change; note that `Range<usize>` and `Range<isize>` are always ExactSizeIterators. [breaking-change]
…=alexcrichton Fixes rust-lang#22047 `Range<u64>` and `Range<i64>` may be longer than usize::MAX on 32-bit platforms, and thus they cannot fulfill the protocol for ExactSizeIterator. We don't want a nonobvious platform dependency in basic iterator traits, so the trait impl is removed. The logic of this change assumes that usize is at least 32-bit. This is technically a breaking change; note that `Range<usize>` and `Range<isize>` are always ExactSizeIterators. [breaking-change]
What does
(0..std::u64::MAX).size_hint()
return on a 32-bit build?Range<u64>
andRange<i64>
cannot fulfill the requirements of the ExactSizeIterator trait, and the implementations must be removed.The text was updated successfully, but these errors were encountered: