How do you enable a Rust “crate feature”?

Specify the dependencies in Cargo.toml like so:

[dependencies]
rand = { version = "0.7.2", features = ["small_rng"] }

Alternatively:

[dependencies.rand]
version = "0.7.2"
features = ["small_rng"]

Both work.

Leave a Comment