cargo-hack
Cargo subcommand for testing all feature flag combinations of a crate. Useful for catching compilation failures hidden behind optional features.
Install
cargo install cargo-hackUsage
# check every feature combination compiles
cargo hack check --feature-powerset
# test with each feature enabled individually
cargo hack test --each-feature
# exclude specific features
cargo hack check --feature-powerset --exclude-features defaultFlags
| Flag | Effect |
|---|---|
--feature-powerset | Test all combinations of features |
--each-feature | Test each feature individually |
--no-dev-deps | Skip dev-dependencies |
--clean-per-run | Clean build artifacts between runs |