Skip to content

Commit ec277ba

Browse files
committed
Pluralize: drop PluralCount newtype, take plain u64
Cast `usize`/`u32` etc. at the call site with `as u64`. The 25-line `Into<PluralCount>` wrapper bought callers a missing cast at the cost of an unusual signature; replacing it with a plain `u64` arg matches what every other Rust codebase does and trims the helper to two ~6-line fns. Test-only `chunks` counters in the AI smoke tests flipped from `usize` to `u64` for the same reason (no cast at the format site). Caught and fixed via `cargo check --tests`: 23 call sites needed `as u64`; clippy + 1942 rust-tests stayed green.
1 parent e070fc3 commit ec277ba

17 files changed

Lines changed: 44 additions & 72 deletions

apps/desktop/src-tauri/src/ai/api_keys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn save(provider_id: &str, api_key: &str) -> Result<(), AiApiKeyError> {
5454
crate::secrets::store().set(&key, api_key.as_bytes())?;
5555
info!(
5656
"AI API key saved for provider {provider_id} ({})",
57-
pluralize(key_len, "byte")
57+
pluralize(key_len as u64, "byte")
5858
);
5959
Ok(())
6060
}

apps/desktop/src-tauri/src/ai/client_local_llama_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async fn local_streaming_emits_multiple_chunks_progressively() {
6969
.await
7070
.expect("stream should open against local server");
7171

72-
let mut chunks: usize = 0;
72+
let mut chunks: u64 = 0;
7373
let mut total = String::new();
7474
let mut first_chunk_at = None;
7575
while let Some(item) = stream.next().await {

apps/desktop/src-tauri/src/ai/client_real_anthropic_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async fn smoke_claude_haiku_stream() {
7575
.expect("stream open");
7676

7777
let mut text = String::new();
78-
let mut chunks: usize = 0;
78+
let mut chunks: u64 = 0;
7979
while let Some(item) = stream.next().await {
8080
let chunk = item.expect("chunk ok");
8181
text.push_str(&chunk);

apps/desktop/src-tauri/src/ai/client_real_openai_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ async fn collect_stream(backend: &AiBackend, model_label: &str) -> String {
113113
.await
114114
.expect("stream open");
115115
let mut text = String::new();
116-
let mut chunks: usize = 0;
116+
let mut chunks: u64 = 0;
117117
while let Some(item) = stream.next().await {
118118
let chunk = item.expect("chunk ok");
119119
text.push_str(&chunk);

apps/desktop/src-tauri/src/ai/extract.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,6 @@ pub fn extract_bundled_llama_server<R: Runtime>(app: &AppHandle<R>, ai_dir: &Pat
8585
return Err(String::from("llama-server binary not found in bundled resources"));
8686
}
8787

88-
log::debug!("AI: copied {} from bundled resources", pluralize(copied_count, "file"));
88+
log::debug!("AI: copied {} from bundled resources", pluralize(copied_count as u64, "file"));
8989
Ok(())
9090
}

apps/desktop/src-tauri/src/ai/manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ async fn wait_for_server_health(ai_dir: &Path, pid: u32, port: u16) -> Result<()
995995
if let Some((line_count, last_line)) = log_diagnostics(ai_dir) {
996996
log::debug!(
997997
"AI server: log has {}, last: {last_line}",
998-
pluralize(line_count, "line")
998+
pluralize(line_count as u64, "line")
999999
);
10001000
}
10011001
}

apps/desktop/src-tauri/src/commands/error_reporter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ fn validate_user_note(user_note: Option<String>) -> Result<Option<String>, Strin
126126
match user_note {
127127
Some(n) if n.chars().count() > MAX_USER_NOTE_CHARS => Err(format!(
128128
"User note is too long ({}). Maximum is {}.",
129-
pluralize(n.chars().count(), "char"),
130-
pluralize(MAX_USER_NOTE_CHARS, "char"),
129+
pluralize(n.chars().count() as u64, "char"),
130+
pluralize(MAX_USER_NOTE_CHARS as u64, "char"),
131131
)),
132132
other => Ok(other),
133133
}

apps/desktop/src-tauri/src/file_system/volume/smb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4234,7 +4234,7 @@ mod tests {
42344234
if total_iters < 20 {
42354235
panic!(
42364236
"soak ran only {}; need at least 20 to compute drift (set CMDR_SOAK_ITERATIONS=100 minimum)",
4237-
crate::pluralize::pluralize(total_iters, "iteration")
4237+
crate::pluralize::pluralize(total_iters as u64, "iteration")
42384238
);
42394239
}
42404240

apps/desktop/src-tauri/src/indexing/aggregator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub fn compute_all_aggregates_reported(
8484
let dir_count = dir_entries.len();
8585
log::debug!(
8686
"Aggregation: starting bottom-up computation for {}",
87-
pluralize_with(dir_count, "directory", "directories")
87+
pluralize_with(dir_count as u64, "directory", "directories")
8888
);
8989

9090
// Bulk-load direct children stats for ALL parent IDs in two SQL queries
@@ -278,7 +278,7 @@ pub fn compute_subtree_aggregates(conn: &Connection, root: &str) -> Result<u64,
278278
let dir_count = dir_entries.len();
279279
log::debug!(
280280
"Subtree aggregation: starting bottom-up computation for {} under {root}",
281-
pluralize_with(dir_count, "directory", "directories")
281+
pluralize_with(dir_count as u64, "directory", "directories")
282282
);
283283

284284
// Load direct children stats scoped to this subtree via recursive CTE
@@ -337,7 +337,7 @@ pub fn backfill_missing_dir_stats(conn: &Connection) -> Result<u64, IndexStoreEr
337337
let count = missing_ids.len();
338338
log::debug!(
339339
"Backfill: {} missing dir_stats, computing...",
340-
pluralize_with(count, "directory", "directories")
340+
pluralize_with(count as u64, "directory", "directories")
341341
);
342342

343343
// Load ALL directory entries for the topological sort (we need the full

apps/desktop/src-tauri/src/indexing/enrichment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub fn enrich_entries_with_index(entries: &mut [FileEntry]) {
120120
None => return,
121121
};
122122

123-
log::debug!("enrich: {} under {parent_path}", pluralize(dir_count, "dir"));
123+
log::debug!("enrich: {} under {parent_path}", pluralize(dir_count as u64, "dir"));
124124

125125
// Use the integer-keyed fast path: resolve parent once, batch-fetch child stats
126126
if let Err(e) = pool
@@ -136,7 +136,7 @@ pub fn enrich_entries_with_index(entries: &mut [FileEntry]) {
136136
.iter()
137137
.filter(|e| e.is_directory && !e.is_symlink && e.recursive_size.is_some())
138138
.count();
139-
log::debug!("enrich: {enriched}/{} got sizes", pluralize(dir_count, "dir"));
139+
log::debug!("enrich: {enriched}/{} got sizes", pluralize(dir_count as u64, "dir"));
140140
}
141141

142142
/// Fast path: resolve parent dir → id, get child dir IDs, batch-fetch stats.

0 commit comments

Comments
 (0)