rust-lang / libs-team

The home of the library team
Apache License 2.0
110 stars 18 forks source link

Implement more `ExactSizeIterators` on 64-bit platforms #369

Open yhx-12243 opened 2 months ago

yhx-12243 commented 2 months ago

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.