知识卡片
rustfix应用编译建议
cargo fix 可应用有明确更正方式的编译器建议。书中把未使用的 i 改为 _i。应用后检查差异,再通过原测试验证程序意图,尤其是使用建议做 edition 迁移时。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 附录 D · 开发工具 Automatic Formatting with rustfmt · 查看原书依据
The warning suggests that we use _i as a name instead: the underscore indicates that we intend for this variable to be unused. We can automatically apply that suggestion using the rustfix tool by running the command cargo fix:
参考来源
- 位置:《The Rust Programming Language(第2版)》附录 D · 开发工具(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/b04.xhtml`,块 0015)
- 结论依据:原文演示将未用变量改名为带下划线的编译建议。
- 原始内容:The warning suggests that we use _i as a name instead: the underscore indicates that we intend for this variable to be unused. We can automatically apply that suggestion using the rustfix tool by running the command cargo fix: