如何在Rust中将编译器标志传递给子crate?

5
我有两个木箱: ABA 依赖于 B,而 B 有一个名为 some_feature 的功能。
我可以通过运行 cargo build --features=some_feature 来使用 cargo 构建 B ,但当编译 A 时,如何设置与 B 的底层木箱一样的功能?我可以选择启用或禁用 some_feature 吗?
2个回答

7
您可以简单地转发A中指定的功能:
# A/Cargo.toml

[features]
some-feature = ["B/some-feature"]

[dependencies]
B = "*"

如果您将--features=some_feature传递给A,则会使用--features=some_feature编译B


0

你只需要配置清单文件,就像文档所说的那样简单:

[dependencies.awesome]
version = "1.3.5"
default-features = false # do not include the default features, and optionally
                         # cherry-pick individual features
features = ["secure-password", "civet"]

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接