货物.toml:
[features]
parallel = ["rayon"]
[dependencies.rayon]
version = "1.5"
optional = true
Run Code Online (Sandbox Code Playgroud)
库.rs:
#[cfg(feature = "parallel")]
pub mod par;
Run Code Online (Sandbox Code Playgroud)
锈迹分析仪:
code is inactive due to #[cfg] directives: feature = "parallel" is disabled
Run Code Online (Sandbox Code Playgroud)
如何启用可选依赖项?
您可以将 Rust 分析器配置选项设置rust-analyzer.cargo.features为一个数组,其中包含您希望 RA 认为处于活动状态的功能列表。
您还可以将其值设置为“all”,以启用项目中的所有功能。
设置这些的方法根据您使用的 IDE 的不同而有所不同 - 例如,如果使用 VS Code,您可以通过 Rust 分析器的“扩展设置”进行设置。
这假设您询问如何激活 Rust Analyzer 中的功能 - 要在从 Cargo 构建或运行时激活它们,只需使用该--features选项。
请参阅:Rust 分析仪手册
| 归档时间: |
|
| 查看次数: |
3026 次 |
| 最近记录: |