Rust cargo:启用特定功能后如何为 dep 使用不同的功能?
Rust cargo: how to use different features for a dep when a particular feature is enabled?
例如,我定义了 2 个没有依赖关系的特征:
[features]
default = []
py2 = []
py3 = []
基于 selected 功能 (--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
我可以这样做吗?或者我也可以 select 从命令行依赖的特性吗?
已讨论 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
我在文档或官方页面上什么也没看到。
例如,我定义了 2 个没有依赖关系的特征:
[features]
default = []
py2 = []
py3 = []
基于 selected 功能 (--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
我可以这样做吗?或者我也可以 select 从命令行依赖的特性吗?
已讨论 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
我在文档或官方页面上什么也没看到。