| Crates.io | list-features |
| lib.rs | list-features |
| version | 0.1.2 |
| created_at | 2025-07-30 16:39:07.63327+00 |
| updated_at | 2025-08-17 16:22:18.3219+00 |
| description | Extracts the list of enabled feature flags during compilation. |
| homepage | |
| repository | https://framagit.org/dder/list-features |
| max_upload_size | |
| id | 1773784 |
| size | 20,249 |
Extracts the list of enabled feature flags during compilation. These flags can then be saved and displayed at run-time.
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 :)
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.
// In build.rs
let out_dir = std::env::var("OUT_DIR").unwrap();
let build_info_path = format!("{out_dir}/build_info.rs");
let features = list_features::list_enabled_as_string("ENABLED_FEATURES");
std::fs::write(build_info_path, features).unwrap();
// In main.rs
include!(concat!(env!("OUT_DIR"), "/build_info.rs"));
println!("Features: {:?}", ENABLED_FEATURES);
See also the example crate and the docs.
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:
version = 4 to version = 3 in Cargo.lock.rustup install 1.77.0-x86_64-pc-windows-gnu.cargo +1.77 clippy
cargo +1.77 test --features test