gpt4 book ai didi

rust cargo : how to use different features for a dep when a particular feature is enabled?

转载 作者:行者123 更新时间:2023-11-29 07:53:42 29 4
gpt4 key购买 nike

例如,我定义了 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/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com