Skip to content

Commit be052fe

Browse files
author
mudssky
committed
build(rustfmt): 添加 rustfmt 配置文件以统一代码格式
添加 rustfmt.toml 配置文件,设置代码最大宽度为 100 字符,启用导入排序,并配置链式调用换行宽度为 80 字符以提升代码可读性
1 parent 9251a52 commit be052fe

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

config/rust/rustfmt.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# rustfmt 配置
2+
# 更多配置项请参考:https://rust-lang.github.io/rustfmt/?version=v1.7.0&edition=2024&search=
3+
4+
# 单行代码的最大宽度。当代码超出此宽度时,rustfmt 会尝试将其格式化为多行。
5+
max_width = 100
6+
7+
# 是否对导入(use 语句)进行排序。设置为 true 会按照字母顺序对导入进行排序和分组。
8+
reorder_imports = true
9+
10+
# 链式方法调用的最大宽度。当链式调用超出此宽度时,rustfmt 会将其拆分为多行。
11+
# 通常设置为略小于 `max_width` 的值,以便在达到行宽限制前提前换行,提高可读性。
12+
chain_width = 80

0 commit comments

Comments
 (0)