知识卡片

操作参考卡 · 6075.c.6 · 生成模型:未记录

rustfix应用编译建议

理解等级:中级

cargo fix 可应用有明确更正方式的编译器建议。书中把未使用的 i 改为 _i。应用后检查差异,再通过原测试验证程序意图,尤其是使用建议做 edition 迁移时。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《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: