list-features
Extracts the list of enabled feature flags during compilation. These flags can then be saved and displayed at run-time.
Highlights
- Zero dependencies: This crate has no dependency and won’t, in its typical use case, be a run-time dependency.
- Low Rust version requirement: Compatible with Rust version 1.58 (see also Windows 7 compatibility).
- Tiny: It does one thing and there’s no plan to add more. Excluding tests/docs, the library is currently under 80 lines of code.
If these characteristics are not important for your use case, the built or toml crates might be more appropriate for your needs. Otherwise, stick around :)
Usage
Add list-features as a build dependency.
Use it in your build.rs script to obtain the list of enabled features for the current build.
Include that list where you need it, for instance in main.rs.
Example
// In build.rs
let out_dir = var.unwrap;
let build_info_path = format!;
let features = list_enabled_as_string;
write.unwrap;
// In main.rs
include!;
println!;
See also the example crate and the docs.
Windows 7 compatibility
The minimum required Rust version is 1.58. While this is unlikely to change in the foreseeable future, the main objective is to remain at or below Rust 1.77, so as to preserve Windows 7 compatibility.
To test with Rust 1.77:
- Change
version = 4toversion = 3inCargo.lock. - Install the 1.77 target:
rustup install 1.77.0-x86_64-pc-windows-gnu. - Then run clippy and the tests as follows:
cargo +1.77 clippy
cargo +1.77 test --features test