Rust 如何在Cargo.toml中启用每个平台的板条箱功能?

Rust 如何在Cargo.toml中启用每个平台的板条箱功能?,rust,rust-cargo,Rust,Rust Cargo,如何在Cargo.toml配置中为每个平台启用板条箱功能?我试过两种方法,都不管用 方法1: [target.'cfg(windows)'.dependencies.rusqlite] version = "0.19.0" features = ["bundled"] [target.'cfg(unix)'.dependencies.rusqlite] # same behavior with cfg(not(windows)) version = "0.19.0" 方法2: [target

如何在Cargo.toml配置中为每个平台启用板条箱功能?我试过两种方法,都不管用

方法1:

[target.'cfg(windows)'.dependencies.rusqlite]
version = "0.19.0"
features = ["bundled"]

[target.'cfg(unix)'.dependencies.rusqlite] # same behavior with cfg(not(windows))
version = "0.19.0"
方法2:

[target.'cfg(windows)'.dependencies]
rusqlite = { version = "0.19.0", features = ["bundled"] }

[target.'cfg(unix)'.dependencies]
rusqlite = { version = "0.19.0" }
我试图仅在Windows平台上使用“捆绑”功能,但无论我尝试以何种方式配置cargo,在Ubuntu系统上构建时,它总是添加“捆绑”功能

是否可以仅在一个平台上启用功能

是否可以仅在一个平台上启用功能

不,这是不可能的,因为

另见:


不幸的是,Cargo的功能系统目前非常有限,使跨平台应用程序的工作非常痛苦