orlp / slotmap

Slotmap data structure for Rust
zlib License
1.12k stars 70 forks source link

Only apply the `unstable` feature on nightly toolchains. #45

Closed olson-sean-k closed 3 years ago

olson-sean-k commented 3 years ago

The unstable feature interacts poorly with non-nightly toolchains and Cargo options (in particular --all-features). Building slotmap with cargo build --all-features causes errors when using a stable toolchain, for example. This change uses a build script to detect nightly toolchains and further gates the unstable feature on a nightly configuration. This prevents errors caused by using the feature attribute with non-nightly toolchains.

The use of rustversion in a build script is a known pattern. See that crate for more. Please take a look. Thanks!