Enable all cargo features

how do i add a dependency with all its features enabled?

It's up to the library author(s) if they want to support such use case.

1 Like

For most libraries, features add functionality for very specific use cases, like interoperation with a particular other library. Activating all features will just increase your compile times to little benefit. It may even cause compilation to fail (e.g. a feature not supported for the target, or which requires some external native library or other dependency).

3 Likes

Features can even be mutually exclusive (they can enable different functionalities under the same API or change the way functions work). It another compile-time error case.

2 Likes

You have to list them all. There's no shortcut for this.

docs.rs has a Feature Flags in the menu, where you can find what you can enable:

https://docs.rs/crate/clap/4.3.19/features

1 Like

That is a misuse of features. Sometimes, it is the least bad option, but it is a misuse of features.

A consequence of this is that features should be additive. That is, enabling a feature should not disable functionality, and it should usually be safe to enable any combination of features. A feature should not introduce a SemVer-incompatible change.

The Cargo Book

5 Likes

Note that Cargo does have an --all-features flag, commonly used by rustdoc, but it only applies to your crate, not your dependencies.