cargo-hack
1 min read

Cargo subcommand for testing all feature flag combinations of a crate. Useful for catching compilation failures hidden behind optional features.

Install

sh
cargo install cargo-hack

Usage

sh
# 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 default

Flags

FlagEffect
--feature-powersetTest all combinations of features
--each-featureTest each feature individually
--no-dev-depsSkip dev-dependencies
--clean-per-runClean build artifacts between runs