| 配置 | rustfmt.toml |
|---|---|
| 常用项 | max_width / edition / use_small_heuristics |
| 应用 | cargo fmt --all |
配置与命令
配置与命令
max_width = 100
edition = "2021"
# 命令行
cargo fmt --all -- --checkCI 用 cargo fmt --check:只检查不修改,阻止未格式化代码合入。
rustfmt 按官方风格重排 Rust 代码:通过 rustfmt.toml 调整少数稳定选项,多模块项目用 skip_children 或按文件就地忽略,cargo fmt 负责批量应用。
| 配置 | rustfmt.toml |
|---|---|
| 常用项 | max_width / edition / use_small_heuristics |
| 应用 | cargo fmt --all |
max_width = 100
edition = "2021"
# 命令行
cargo fmt --all -- --check