Skip to content

Commit 9b1b158

Browse files
committed
docs: align single-letter guidance with stricter perfectionist rules
The `perfectionist` upgrade in #433 tightened the `single_letter_let_binding` rule, which no longer permits single-letter `let` bindings for interchangeable test fixtures. That leeway was the reason #433 renamed fixtures such as `a`/`b`/`c` to descriptive names. Remove the now-contradicted test-fixtures exception from CONTRIBUTING.md and the AI instruction templates, and state that `let` bindings must use descriptive names in test code as well as non-test code. https://claude.ai/code/session_01CMrfXtuzxpSbchSJNuwboK
1 parent 78ce4d9 commit 9b1b158

5 files changed

Lines changed: 5 additions & 13 deletions

File tree

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c
88
- Version releases are the only exception. The commit message is just the version number, such as `0.21.1`.
99
- Write documentation, comments, and other prose for ease of understanding first. Prefer a formal tone when it does not hurt clarity, and use complete sentences. Avoid mid-sentence breaks introduced by em dashes or long parenthetical clauses. Em dashes are a reliable symptom of loose phrasing; when one appears, restructure the surrounding sentence so each clause stands on its own rather than swapping the em dash for another punctuation mark.
1010
- Use descriptive names for generics, such as `Size` and `Report`. Do not use single letters.
11-
- Use descriptive names for variables and closure parameters. Single letters are permitted only in these cases: (1) conventional names like `n` for count or `f` for formatter; (2) comparison closures like `|a, b|`; (3) trivial single-expression closures; (4) fold accumulators; (5) index variables `i`/`j`/`k` in short closures or index-based loops; and (6) test fixtures with identical roles. Single letters are never permitted in multi-line functions or closures.
11+
- Use descriptive names for variables and closure parameters. Single letters are permitted only in these cases: (1) conventional names like `n` for count or `f` for formatter; (2) comparison closures like `|a, b|`; (3) trivial single-expression closures; (4) fold accumulators; and (5) index variables `i`/`j`/`k` in short closures or index-based loops. Single letters are never permitted in `let` bindings, including test fixtures, nor in multi-line functions or closures.
1212
- Use `pipe-trait` to chain through unary functions such as constructors, `Some`, `Ok`, and free functions. Use it to flatten nested calls and to continue method chains. Do not use it for simple standalone calls; prefer `foo(value)` over `value.pipe(foo)`.
1313
- Prefer `where` clauses when a type has multiple trait bounds.
1414
- For error types, only derive `Display` and `Error` from `derive_more` when each is actually needed. Not all displayable types are errors.

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c
88
- Version releases are the only exception. The commit message is just the version number, such as `0.21.1`.
99
- Write documentation, comments, and other prose for ease of understanding first. Prefer a formal tone when it does not hurt clarity, and use complete sentences. Avoid mid-sentence breaks introduced by em dashes or long parenthetical clauses. Em dashes are a reliable symptom of loose phrasing; when one appears, restructure the surrounding sentence so each clause stands on its own rather than swapping the em dash for another punctuation mark.
1010
- Use descriptive names for generics, such as `Size` and `Report`. Do not use single letters.
11-
- Use descriptive names for variables and closure parameters. Single letters are permitted only in these cases: (1) conventional names like `n` for count or `f` for formatter; (2) comparison closures like `|a, b|`; (3) trivial single-expression closures; (4) fold accumulators; (5) index variables `i`/`j`/`k` in short closures or index-based loops; and (6) test fixtures with identical roles. Single letters are never permitted in multi-line functions or closures.
11+
- Use descriptive names for variables and closure parameters. Single letters are permitted only in these cases: (1) conventional names like `n` for count or `f` for formatter; (2) comparison closures like `|a, b|`; (3) trivial single-expression closures; (4) fold accumulators; and (5) index variables `i`/`j`/`k` in short closures or index-based loops. Single letters are never permitted in `let` bindings, including test fixtures, nor in multi-line functions or closures.
1212
- Use `pipe-trait` to chain through unary functions such as constructors, `Some`, `Ok`, and free functions. Use it to flatten nested calls and to continue method chains. Do not use it for simple standalone calls; prefer `foo(value)` over `value.pipe(foo)`.
1313
- Prefer `where` clauses when a type has multiple trait bounds.
1414
- For error types, only derive `Display` and `Error` from `derive_more` when each is actually needed. Not all displayable types are errors.

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c
88
- Version releases are the only exception. The commit message is just the version number, such as `0.21.1`.
99
- Write documentation, comments, and other prose for ease of understanding first. Prefer a formal tone when it does not hurt clarity, and use complete sentences. Avoid mid-sentence breaks introduced by em dashes or long parenthetical clauses. Em dashes are a reliable symptom of loose phrasing; when one appears, restructure the surrounding sentence so each clause stands on its own rather than swapping the em dash for another punctuation mark.
1010
- Use descriptive names for generics, such as `Size` and `Report`. Do not use single letters.
11-
- Use descriptive names for variables and closure parameters. Single letters are permitted only in these cases: (1) conventional names like `n` for count or `f` for formatter; (2) comparison closures like `|a, b|`; (3) trivial single-expression closures; (4) fold accumulators; (5) index variables `i`/`j`/`k` in short closures or index-based loops; and (6) test fixtures with identical roles. Single letters are never permitted in multi-line functions or closures.
11+
- Use descriptive names for variables and closure parameters. Single letters are permitted only in these cases: (1) conventional names like `n` for count or `f` for formatter; (2) comparison closures like `|a, b|`; (3) trivial single-expression closures; (4) fold accumulators; and (5) index variables `i`/`j`/`k` in short closures or index-based loops. Single letters are never permitted in `let` bindings, including test fixtures, nor in multi-line functions or closures.
1212
- Use `pipe-trait` to chain through unary functions such as constructors, `Some`, `Ok`, and free functions. Use it to flatten nested calls and to continue method chains. Do not use it for simple standalone calls; prefer `foo(value)` over `value.pipe(foo)`.
1313
- Prefer `where` clauses when a type has multiple trait bounds.
1414
- For error types, only derive `Display` and `Error` from `derive_more` when each is actually needed. Not all displayable types are errors.

CONTRIBUTING.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,6 @@ Use **descriptive names** for variables and closure parameters by default. Singl
134134
.fold(PathBuf::new(), |acc, x| acc.join(x))
135135
```
136136

137-
- **Test fixtures:** `let a`, `let b`, `let c` for interchangeable specimens with identical roles in equality or comparison tests. Do not use single letters when the variables have distinct roles; use `actual`/`expected` or similar descriptive names instead.
138-
139-
```rust
140-
let a = vec![3, 1, 2].into_iter().collect::<BTreeSet<_>>();
141-
let b = vec![2, 3, 1].into_iter().collect::<BTreeSet<_>>();
142-
assert_eq!(a, b);
143-
```
144-
145137
#### When single-letter names are NOT allowed
146138

147139
- **Multi-line functions and closures:** Use a descriptive name when a function or closure body spans multiple lines. Examples include a body that contains a `let` binding followed by another expression, or a body with multiple chained operations.
@@ -160,7 +152,7 @@ Use **descriptive names** for variables and closure parameters by default. Singl
160152
})
161153
```
162154

163-
- **`let` bindings in non-test code:** Always use descriptive names.
155+
- **`let` bindings:** Always use descriptive names, in test code as well as non-test code. This includes interchangeable specimens in equality or comparison tests, where names such as `first_order` and `second_order` are preferred over `a` and `b`.
164156

165157
```rust
166158
// Good

template/ai-instructions/shared.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c
88
- Version releases are the only exception. The commit message is just the version number, such as `0.21.1`.
99
- Write documentation, comments, and other prose for ease of understanding first. Prefer a formal tone when it does not hurt clarity, and use complete sentences. Avoid mid-sentence breaks introduced by em dashes or long parenthetical clauses. Em dashes are a reliable symptom of loose phrasing; when one appears, restructure the surrounding sentence so each clause stands on its own rather than swapping the em dash for another punctuation mark.
1010
- Use descriptive names for generics, such as `Size` and `Report`. Do not use single letters.
11-
- Use descriptive names for variables and closure parameters. Single letters are permitted only in these cases: (1) conventional names like `n` for count or `f` for formatter; (2) comparison closures like `|a, b|`; (3) trivial single-expression closures; (4) fold accumulators; (5) index variables `i`/`j`/`k` in short closures or index-based loops; and (6) test fixtures with identical roles. Single letters are never permitted in multi-line functions or closures.
11+
- Use descriptive names for variables and closure parameters. Single letters are permitted only in these cases: (1) conventional names like `n` for count or `f` for formatter; (2) comparison closures like `|a, b|`; (3) trivial single-expression closures; (4) fold accumulators; and (5) index variables `i`/`j`/`k` in short closures or index-based loops. Single letters are never permitted in `let` bindings, including test fixtures, nor in multi-line functions or closures.
1212
- Use `pipe-trait` to chain through unary functions such as constructors, `Some`, `Ok`, and free functions. Use it to flatten nested calls and to continue method chains. Do not use it for simple standalone calls; prefer `foo(value)` over `value.pipe(foo)`.
1313
- Prefer `where` clauses when a type has multiple trait bounds.
1414
- For error types, only derive `Display` and `Error` from `derive_more` when each is actually needed. Not all displayable types are errors.

0 commit comments

Comments
 (0)