例如,我定义了 2 个没有依赖关系的特性:
[features]
default = []
py2 = []
py3 = []
基于选定的功能 (--features py3
) 我想为依赖项 (cpython
) 启用不同的功能:
[dependencies.cpython]
default-features = false
# features = ["python27-sys"] I want to select this if py2 is enabled
features = ["python3-sys"]
optional = true
我可以这样做吗?或者我也可以从命令行为依赖项选择功能吗?
最佳答案
讨论了here .可以使用 /
来完成。
[features]
default = []
py2 = ["cpython", "cpython/python27-sys"]
py3 = ["cpython", "cpython/python3-sys"]
unstable = []
[dependencies.cpython]
# git = "https://github.com/dgrunwald/rust-cpython.git"
default-features = false
optional = true
我在文档或官方页面上什么也没看到。
关于 rust cargo : how to use different features for a dep when a particular feature is enabled?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41439912/