You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/dev/style.md
+7-6Lines changed: 7 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -67,7 +67,8 @@ as long as they are still readable.
67
67
68
68
## Order of Imports
69
69
70
-
We separate import groups with blank lines
70
+
Separate import groups with blank lines.
71
+
Use one `use` per crate.
71
72
72
73
```rust
73
74
modx;
@@ -92,7 +93,7 @@ Order them in "suggested reading order" for a person new to the code base.
92
93
93
94
## ImportStyle
94
95
95
-
Itemsfrom `hir` and `ast` should be used qualified:
96
+
Qualify items from `hir` and `ast`.
96
97
97
98
```rust
98
99
// Good
@@ -144,20 +145,20 @@ struct Foo {
144
145
145
146
## Variable Naming
146
147
147
-
We generally use boring and long names for local variables ([yay code completion](https://github.com/rust-analyzer/rust-analyzer/pull/4162#discussion_r417130973)).
148
+
Use boring and long names for local variables ([yay code completion](https://github.com/rust-analyzer/rust-analyzer/pull/4162#discussion_r417130973)).
148
149
The default name is a lowercased name of the type: `global_state: GlobalState`.
149
150
Avoid ad-hoc acronyms and contractions, but use the ones that exist consistently (`db`, `ctx`, `acc`).
150
151
The default name for "result of the function" local variable is `res`.
151
152
The default name for "I don't really care about the name" variable is `it`.
152
153
153
154
## Collection types
154
155
155
-
We prefer`rustc_hash::FxHashMap` and `rustc_hash::FxHashSet` instead of the ones in `std::collections`.
156
+
Prefer`rustc_hash::FxHashMap` and `rustc_hash::FxHashSet` instead of the ones in `std::collections`.
156
157
They use a hasher that's slightly faster and using them consistently will reduce code size by some small amount.
157
158
158
159
## Preconditions
159
160
160
-
Function preconditions should generally be expressed in types and provided by the caller (rather than checked by callee):
161
+
Express function preconditions in types and force the caller to provide them (rather than checking in callee):
161
162
162
163
```rust
163
164
// Good
@@ -205,7 +206,7 @@ If the line is too long, you want to split the sentence in two :-)
205
206
206
207
We don't have specific rules around git history hygiene.
207
208
Maintaining clean git history is encouraged, but not enforced.
208
-
We use rebase workflow, it's OK to rewrite history during PR review process.
209
+
Use rebase workflow, it's OK to rewrite history during PR review process.
209
210
210
211
Avoid @mentioning people in commit messages and pull request descriptions(they are added to commit message by bors).
211
212
Such messages create a lot of duplicate notification traffic during rebases.
0 commit comments