num-bigint
,并且可选依赖于 rand
:
[dependencies]
num-bigint = { version = "0.2" }
rand = { version = "0.7", optional = true }
当我的板条箱上禁用
rand
时,一切都很好。
当我的箱子上启用
rand
时,我希望也启用 rand
的 num-bigint
功能。我怎样才能做到这一点?
这是我尝试过的:
[target.'cfg(feature = "rand")'.dependencies]
num-bigint = { version = "0.2", features = ["rand"] }
这可行,但我收到此警告:
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
我应该忽略警告,还是有更好的方法?我检查了该网页,但找不到任何有用的信息。