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: .github/copilot-instructions.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c
8
8
- Version releases are the only exception: just the version number (e.g. `0.21.1`)
9
9
- Prefer merged imports
10
10
- Use descriptive generic names (`Size`, `Report`), not single letters
11
+
- Use descriptive variable and closure parameter names by default — single letters are only allowed in: conventional names (`n` for count, `f` for formatter), comparison closures (`|a, b|`), trivial single-expression closures, fold accumulators, index variables (`i`/`j`/`k` in short closures or index-based loops only), and test fixtures (identical roles only). Never use single letters in multi-line functions or closures
11
12
- Prefer `where` clauses for multiple trait bounds
Copy file name to clipboardExpand all lines: AGENTS.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c
8
8
- Version releases are the only exception: just the version number (e.g. `0.21.1`)
9
9
- Prefer merged imports
10
10
- Use descriptive generic names (`Size`, `Report`), not single letters
11
+
- Use descriptive variable and closure parameter names by default — single letters are only allowed in: conventional names (`n` for count, `f` for formatter), comparison closures (`|a, b|`), trivial single-expression closures, fold accumulators, index variables (`i`/`j`/`k` in short closures or index-based loops only), and test fixtures (identical roles only). Never use single letters in multi-line functions or closures
11
12
- Prefer `where` clauses for multiple trait bounds
Copy file name to clipboardExpand all lines: CLAUDE.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c
8
8
- Version releases are the only exception: just the version number (e.g. `0.21.1`)
9
9
- Prefer merged imports
10
10
- Use descriptive generic names (`Size`, `Report`), not single letters
11
+
- Use descriptive variable and closure parameter names by default — single letters are only allowed in: conventional names (`n` for count, `f` for formatter), comparison closures (`|a, b|`), trivial single-expression closures, fold accumulators, index variables (`i`/`j`/`k` in short closures or index-based loops only), and test fixtures (identical roles only). Never use single letters in multi-line functions or closures
11
12
- Prefer `where` clauses for multiple trait bounds
-**Conventional single-letter names:**`n` for a natural number (unsigned integer / count), `f` for a `fmt::Formatter`, and similar well-established conventions from math or the Rust standard library. Note: for indices, use `index`, `idx`, or `*_index` (e.g., `row_index`) — not `n`. (For `i`/`j`/`k`, see the dedicated rule below.)
-**Index variables (`i`, `j`, `k`):** These may only be used in two contexts: (1) short closures, and (2) index-based loops/iterations (rare in Rust). In all other cases, use `index`, `idx`, or `*_index`.
-**Trivial single-expression closures:** A closure whose body is a single field access, method call, or wrapper may use a single letter when the type and purpose are obvious from context.
131
+
132
+
```rust
133
+
.pipe(|x|vec![x])
134
+
```
135
+
136
+
-**Fold accumulators:**`acc` for the accumulator and a single letter for the element in trivial folds.
137
+
138
+
```rust
139
+
.fold(PathBuf::new(), |acc, x|acc.join(x))
140
+
```
141
+
142
+
-**Test fixtures:**`let a`, `let b`, `let c` for interchangeable specimens with identical roles in equality or comparison tests (e.g., testing commutativity). Do not use single letters when the variables have distinct roles — use `actual`/`expected` or similar descriptive names instead.
-**Multi-line functions and closures:** If a function or closure body spans multiple lines (e.g., contains a `let` binding followed by another expression, or multiple chained operations), use a descriptive name.
153
+
154
+
```rust
155
+
// Good
156
+
.map(|tree_row| {
157
+
letcolumns=build_columns(tree_row);
158
+
format_row(&columns)
159
+
})
160
+
161
+
// Bad
162
+
.map(|t| {
163
+
letcolumns=build_columns(t);
164
+
format_row(&columns)
165
+
})
166
+
```
167
+
168
+
-**`let` bindings in non-test code:** Always use descriptive names.
169
+
170
+
```rust
171
+
// Good
172
+
letmetadata=entry.metadata()?;
173
+
// Bad
174
+
letm=entry.metadata()?;
175
+
```
176
+
177
+
-**Function and method parameters:** Always use descriptive names, except for conventional single-letter names listed above (`n`, `f`, etc.).
178
+
179
+
-**Closures with non-obvious context:** If the type or purpose is not immediately clear from the surrounding method chain, use a descriptive name.
180
+
181
+
```rust
182
+
// Good — not obvious what the closure receives
183
+
.filter_map(|entry|matchentry { _=>todo!() })
184
+
.for_each(|child|child.par_sort_by(compare))
185
+
186
+
// Bad — reader must look up what .filter receives
187
+
.filter(|x|x.get_mount_point() ==mount_point)
188
+
```
189
+
98
190
### Trait Bounds
99
191
100
192
Prefer `where` clauses over inline bounds when there are multiple constraints:
0 commit comments