Skip to content
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

Range<u64> implements ExactSizeIterator #22047

Closed
bluss opened this Issue Feb 7, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@bluss
Copy link
Contributor

bluss commented Feb 7, 2015

What does (0..std::u64::MAX).size_hint() return on a 32-bit build? Range<u64> and Range<i64> cannot fulfill the requirements of the ExactSizeIterator trait, and the implementations must be removed.

@sfackler sfackler added the A-libs label Feb 7, 2015

@bluss

This comment has been minimized.

Copy link
Contributor Author

bluss commented Feb 7, 2015

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.

@bluss bluss closed this Feb 7, 2015

@bluss bluss reopened this Feb 13, 2015

@bluss

This comment has been minimized.

Copy link
Contributor Author

bluss commented Feb 13, 2015

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.

bluss pushed a commit to bluss/rust that referenced this issue Feb 13, 2015

Ulrik Sverdrup
Remove ExactSizeIterator from 64-bit ranges.
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]

steveklabnik added a commit to steveklabnik/rust that referenced this issue Feb 14, 2015

Rollup merge of rust-lang#22299 - bluss:range-64-is-not-exact-size, r…
…=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]

steveklabnik added a commit to steveklabnik/rust that referenced this issue Feb 15, 2015

Rollup merge of rust-lang#22299 - bluss:range-64-is-not-exact-size, r…
…=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]

Manishearth added a commit to Manishearth/rust that referenced this issue Feb 15, 2015

Rollup merge of rust-lang#22299 - bluss:range-64-is-not-exact-size, r…
…=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]

Manishearth added a commit to Manishearth/rust that referenced this issue Feb 15, 2015

Rollup merge of rust-lang#22299 - bluss:range-64-is-not-exact-size, r…
…=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]

@bors bors closed this in #22299 Feb 16, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.