feat: add support for the Rust range types, guarded by a new_range_api flag#1785
feat: add support for the Rust range types, guarded by a new_range_api flag#1785kristof-mattei wants to merge 2 commits into
new_range_api flag#1785Conversation
dhardy
left a comment
There was a problem hiding this comment.
I agree broadly with the approach here (also with @vks that we don't want a build.rs script for this).
Could you add some testing too? I.e. a use-case for each of the new impls as well as something like this in test.yml:
- name: Rust >= 1.96.0
if: ${{ matrix.variant != 'MSRV' }}
run: |
cargo test --target ${{ matrix.target }} --features=rust_1_96
| // `core::range::RangeTo` is set to be a re-export of `core::ops::RangeTo`: | ||
| // > A Rust version in the near future will also add `core::range::RangeFull` and `core::range::RangeTo` | ||
| // as re-exports from `core::ops` (these do not implement `Iterator` and already implement `Copy`) | ||
| // Source: https://blog.rust-lang.org/2026/05/28/Rust-1.96.0/#new-range-types |
There was a problem hiding this comment.
It suffices to say that we impl SampleRange<_> for the legacy core::ops::{RangeTo, RangeFull} types for compatibility with our MSRV.
(We will presumably get a deprecation warning when updating the MSRV/edition at some point in the future.)
| chacha20 = { version = "0.10.0", default-features = false, features = ["rng"], optional = true } | ||
| chacha20 = { version = "0.10.0", default-features = false, features = [ | ||
| "rng", | ||
| ], optional = true } | ||
| getrandom = { version = "0.4.0", optional = true } | ||
|
|
||
| [dev-dependencies] | ||
| rand_pcg = "0.10" | ||
| # Only to test serde | ||
| postcard = {version = "1.1.3", default-features = false, features = ["alloc"]} | ||
| postcard = { version = "1.1.3", default-features = false, features = ["alloc"] } |
There was a problem hiding this comment.
Can we drop the reformatting please? (Or else push it to a new PR with CI check.)
| # Deprecated option: enable logging | ||
| log = [] | ||
|
|
||
| new_range_api = [] |
There was a problem hiding this comment.
| new_range_api = [] | |
| # Support the std::range types stabilised in Rust 1.96.0. | |
| rust_1_96 = [] |
This should make it clearer that this option only exists to support features requiring a more recent Rust version than the MSRV.
658b663 to
576efe2
Compare
Closes #1784.