Rust货物:如何在启用特定功能时为dep使用不同的功能?

Ser*_*gey 4 rust rust-cargo

例如,我定义了2个没有依赖项的功能:

[features]
default = []
py2 = []
py3 = []
Run Code Online (Sandbox Code Playgroud)

基于所选的功能(--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
Run Code Online (Sandbox Code Playgroud)

我可以这样做吗?或者我也可以从命令行中为依赖项选择功能吗?

Ser*_*gey 5

这里讨论.人们可以做到这一点/.

[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
Run Code Online (Sandbox Code Playgroud)

我在文档或官方网页上看不到任何相关内容.