Rust 日常:提交前先 cargo fmt、clippy、再 check

本地少跑检查,CI 上才爆炸,沟通成本更高。一个轻量顺序:

1、cargo fmt

统一格式,减少无效 diff。

2、cargo clippy

先处理警告里真正的逻辑味道,再谈风格之争。

3、cargo check / test

按项目习惯;改公共 API 时补测。

工具版本与 workspace 配置以仓库为准。把检查写进 git hook 或文档,比口头提醒稳。

来源

[1] Rust 工具链常识整理,2026-10-24。

#Rust #cargo #教程

排序方式 :

成为第一条评论!

Nobody's responded to this post yet. Add your thoughts and get the conversation going.