我有板条箱A和B。A依赖于B并且B有一个名为 的功能some_feature。
我可以B通过运行来使用 Cargo进行构建cargo build --features=some_feature,但是如何设置相同的功能,以便在编译时A可以选择启用或禁用some_feature底层板条箱?BA
您可以简单地转发指定的功能A:
# A/Cargo.toml
[features]
some-feature = ["B/some-feature"]
[dependencies]
B = "*"
Run Code Online (Sandbox Code Playgroud)
如果您传递给B,这将编译。--features=some_feature--features=some_featureA