在 Cargo.toml 中定义 Cargo 配置文件的功能

yni*_*ous 12 rust rust-cargo

我正在使用 Cargo Features ( https://doc.rust-lang.org/cargo/reference/features.html ) 来指定条件编译选项。有没有办法为给定的 Cargo 配置文件启用一组这些功能(https://doc.rust-lang.org/cargo/reference/profiles.html)?

例如,像这样的东西(这似乎不起作用):

[features]
foo = []

[profile.test]
features = ["foo"]
Run Code Online (Sandbox Code Playgroud)

这样我就不必写,cargo test --features "foo"而只是写cargo test

Ari*_*Dey 2

不幸的是,没有任何选项可以帮助指定配置文件的自动功能。

您可以在 shell 中创建别名来运行这些重复的命令,或者更好的是,使用Just,这是一个用 Rust 编写的令人惊叹的命令运行程序。