The scenario is the following: my crate has a dependency on num-bigint
, and an optional dependency on rand
:
[dependencies]
num-bigint = { version = "0.2" }
rand = { version = "0.7", optional = true }
When rand
is disabled on my crate, everything's fine.
When rand
is enabled on my crate, I would like the rand
feature of num-bigint
to be enabled as well. How can I do that?
Here's what I tried:
[target.'cfg(feature = "rand")'.dependencies]
num-bigint = { version = "0.2", features = ["rand"] }
This works, but I'm receiving this warning:
warning: Found `feature = ...` in `target.'cfg(...)'.dependencies`. This key is not supported for selecting dependencies and will not work as expected. Use the [features] section instead: https://doc.rust-lang.org/cargo/reference/features.html
Should I just ignore the warning, or is there a better way to do it? I checked that web page, but I cannot find anything helpful.
Features and dependencies cannot have the same name: `rand`
– Bloodthirsty