Skip to content

Commit 7d8d39b

Browse files
committed
chore(git): merge from master
2 parents d0200ef + 40a6709 commit 7d8d39b

10 files changed

Lines changed: 699 additions & 49 deletions

File tree

.github/copilot-instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c
88
- Version releases are the only exception: just the version number (e.g. `0.21.1`)
99
- Prefer merged imports
1010
- 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
1112
- Prefer `where` clauses for multiple trait bounds
1213
- Derive order: std traits → comparison traits → `Hash` → derive_more → feature-gated
1314
- Custom errors: `#[derive(Debug, Display, Error)]` + `#[non_exhaustive]`

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c
88
- Version releases are the only exception: just the version number (e.g. `0.21.1`)
99
- Prefer merged imports
1010
- 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
1112
- Prefer `where` clauses for multiple trait bounds
1213
- Derive order: std traits → comparison traits → `Hash` → derive_more → feature-gated
1314
- Custom errors: `#[derive(Debug, Display, Error)]` + `#[non_exhaustive]`

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c
88
- Version releases are the only exception: just the version number (e.g. `0.21.1`)
99
- Prefer merged imports
1010
- 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
1112
- Prefer `where` clauses for multiple trait bounds
1213
- Derive order: std traits → comparison traits → `Hash` → derive_more → feature-gated
1314
- Custom errors: `#[derive(Debug, Display, Error)]` + `#[non_exhaustive]`

CONTRIBUTING.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,98 @@ Use **descriptive names** for type parameters, not single letters:
9595

9696
Single-letter generics are acceptable only in very short, self-contained trait impls.
9797

98+
### Variable and Closure Parameter Naming
99+
100+
Use **descriptive names** for variables and closure parameters by default. Single-letter names are permitted only in the specific cases listed below.
101+
102+
#### When single-letter names are allowed
103+
104+
- **Comparison closures:** `|a, b|` in `sort_by`, `cmp`, or similar two-argument comparison callbacks — this is idiomatic Rust.
105+
106+
```rust
107+
sort_reflection_by(&mut tree, |a, b| a.name.cmp(&b.name));
108+
```
109+
110+
- **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.)
111+
112+
```rust
113+
fn with_capacity(n: usize) -> Self { todo!() }
114+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { todo!() }
115+
```
116+
117+
- **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`.
118+
119+
```rust
120+
// OK — short closure
121+
left_indices.zip(right_indices).map(|(i, j)| matrix[i][j])
122+
123+
// OK — index-based loop (rare in Rust)
124+
for i in 0..len { /* ... */ }
125+
126+
// Bad — use a descriptive name instead
127+
let i = items.iter().position(|item| item.is_active()).unwrap();
128+
```
129+
130+
- **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.
143+
144+
```rust
145+
let a = vec![3, 1, 2].into_iter().collect::<BTreeSet<_>>();
146+
let b = vec![2, 3, 1].into_iter().collect::<BTreeSet<_>>();
147+
assert_eq!(a, b);
148+
```
149+
150+
#### When single-letter names are NOT allowed
151+
152+
- **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+
let columns = build_columns(tree_row);
158+
format_row(&columns)
159+
})
160+
161+
// Bad
162+
.map(|t| {
163+
let columns = 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+
let metadata = entry.metadata()?;
173+
// Bad
174+
let m = 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| match entry { _ => 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+
98190
### Trait Bounds
99191

100192
Prefer `where` clauses over inline bounds when there are multiple constraints:

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.89.0
1+
1.94.0

src/app.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::{
2222
time::Duration,
2323
};
2424
use sub::JsonOutputParam;
25-
use sysinfo::Disks;
25+
use sysinfo::{Disk, Disks};
2626

2727
#[cfg(unix)]
2828
use crate::get_size::{GetBlockCount, GetBlockSize};
@@ -141,7 +141,7 @@ impl App {
141141
let threads = match self.args.threads {
142142
Threads::Auto => {
143143
let disks = Disks::new_with_refreshed_list();
144-
if any_path_is_in_hdd::<hdd::RealApi>(&self.args.files, &disks) {
144+
if any_path_is_in_hdd::<Disk, hdd::RealFs>(&self.args.files, &disks) {
145145
eprintln!("warning: HDD detected, the thread limit will be set to 1");
146146
eprintln!("hint: You can pass --threads=max disable this behavior");
147147
Some(1)

0 commit comments

Comments
 (0)