rust - 如何激活可选依赖项?
问题描述
货物.toml:
[features]
parallel = ["rayon"]
[dependencies.rayon]
version = "1.5"
optional = true
lib.rs:
#[cfg(feature = "parallel")]
pub mod par;
锈分析器:
code is inactive due to #[cfg] directives: feature = "parallel" is disabled
如何启用可选依赖项?
解决方案
您可以将 Rust Analyzer 配置选项设置rust-analyzer.cargo.features
为一个数组,其中包含您希望 RA 认为处于活动状态的功能列表。
您还可以设置rust-analyzer.cargo.allFeatures
为 true,以启用项目中的所有功能。
设置这些的方法因您使用的 IDE 而异 - 例如,如果使用 VS Code,您可以通过 Rust Analyzer 的“扩展设置”进行设置。
这假设您询问如何激活 Rust Analyzer 中的功能 - 在从 Cargo 构建或运行时激活它们,只需使用该--features
选项。
推荐阅读
- javascript - 如何使用 javascript 获取已安装的 chrome 扩展列表
- python - 如何通过以元组为参数的函数比较两个变量?
- asp.net - Excel下载未从服务器发生
- dicom - 使用 DCMTK 读取 DICOM 文件的内容序列标签时出现问题
- python - 如何在列出的特定时间运行代码
- python - Django 导出 CSV 给出 HttpResponse 错误
- r - 使用 R 处理一个简单的文本序列以提取所需的输出 nx 1 数据帧
- netty - 如何通过 DTLS 发送数据?
- apache-kafka - logstash kafka 的输出
- javascript - D3 基本地图轮廓未显示