Skip to content

Implement more ExactSizeIterators on 64-bit platforms #369

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

Closed
yhx-12243 opened this issue Apr 19, 2024 · 1 comment
Closed

Implement more ExactSizeIterators on 64-bit platforms #369

yhx-12243 opened this issue Apr 19, 2024 · 1 comment
Labels
api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api

Comments

@yhx-12243
Copy link

Proposal

Implement more ExactSizeIterators on 64-bit platforms

Problem statement

As rust-lang/rust#124056 mentioned, in 64-bit platforms, Range<i64>, Range<u64>, RangeInclusive<i32> and RangeInclusive<u32> can implement ExactSizeIterator and it will be convenient for many operations.

Solution sketch

Just add the implementation and #cfg[]s like other snippets in the same file.

Possible responses

This may break some API when depends hard-wired requirement that it is not implemented, such as
https://github.com/rust-lang/rustc-rayon/blob/f192a484741522bccb411cb5f1da9ec9577d6e27/src/range.rs#L296-L299 ,

But in my opinion, such code is written not very good and can be improved.

@the8472
Copy link
Member

the8472 commented Apr 22, 2025

We discussed this during today's libs-API meeting.

We'd like to have such impls in principle, and along with it things like impl From<u32> for usize and similar. But currently we do not add such target-specific impls to the standard library because it creates portability hazards.
So we have to postpone this issue. It can be revisited if and when Rust has gained a mechanism for crates to opt into limited-portability features.

@the8472 the8472 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api
Projects
None yet
Development

No branches or pull requests

2 participants