Skip to content

Commit 761bce9

Browse files
ndbroadbentclaude
andcommitted
Fix clippy unnecessary_sort_by lints from Rust 1.95
CI runs clippy with -D warnings. Rust 1.95 promoted clippy::unnecessary_sort_by from a warn to a hard error in two pre-existing call sites (sort_by + .cmp(&a) reversed for descending). Replace with sort_by_key + std::cmp::Reverse, which is what clippy suggests and is exactly equivalent. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fbb7a78 commit 761bce9

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src-tauri/src/export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ pub fn export_chats(
260260
}
261261

262262
// Sort by message count descending
263-
exported_chats.sort_by(|a, b| b.messages.len().cmp(&a.messages.len()));
263+
exported_chats.sort_by_key(|c| std::cmp::Reverse(c.messages.len()));
264264

265265
// Write each chat to a separate JSON file and create zip
266266
let zip_path = temp_dir.path().join("export.zip");

src-tauri/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ pub fn list_chats(custom_db_path: Option<&std::path::Path>) -> Result<Vec<ChatIn
196196
.collect();
197197

198198
// Sort by last message date descending (most recent first)
199-
result.sort_by(|a, b| b.1.cmp(&a.1));
199+
result.sort_by_key(|item| std::cmp::Reverse(item.1));
200200

201201
// Extract just the ChatInfo
202202
let result: Vec<ChatInfo> = result.into_iter().map(|(info, _)| info).collect();

0 commit comments

Comments
 (0)