From 1bb281b2a04f6d6d1a8c95a50fbbf1c4ac4caea2 Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Tue, 28 Apr 2026 08:08:23 -0600 Subject: [PATCH] style: Addressed style issues --- src/client/stream.rs | 6 ++---- src/rag/mod.rs | 5 +---- src/utils/input.rs | 6 ++---- src/utils/mod.rs | 4 ++-- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/client/stream.rs b/src/client/stream.rs index d2fe7f7..a14c461 100644 --- a/src/client/stream.rs +++ b/src/client/stream.rs @@ -311,10 +311,8 @@ impl JsonStreamParser { } self.balances.push(ch); } - '[' => { - if self.start.is_some() { - self.balances.push(ch); - } + '[' if self.start.is_some() => { + self.balances.push(ch); } '}' => { self.balances.pop(); diff --git a/src/rag/mod.rs b/src/rag/mod.rs index 1232452..ada86f0 100644 --- a/src/rag/mod.rs +++ b/src/rag/mod.rs @@ -1066,10 +1066,7 @@ fn reciprocal_rank_fusion( ) -> Vec { let rrf_k = top_k * 2; let mut map: IndexMap = IndexMap::new(); - for (document_ids, weight) in list_of_document_ids - .into_iter() - .zip(list_of_weights.into_iter()) - { + for (document_ids, weight) in list_of_document_ids.into_iter().zip(list_of_weights) { for (index, &item) in document_ids.iter().enumerate() { *map.entry(item).or_default() += (1.0 / ((rrf_k + index + 1) as f32)) * weight; } diff --git a/src/utils/input.rs b/src/utils/input.rs index 2dd75dc..ca59db2 100644 --- a/src/utils/input.rs +++ b/src/utils/input.rs @@ -20,10 +20,8 @@ pub fn read_single_key(valid_chars: &[char], default: char, prompt: &str) -> Res KeyCode::Char('c') if modifiers.contains(KeyModifiers::CONTROL) => { break Err(anyhow::anyhow!("Interrupted")); } - KeyCode::Char(c) => { - if valid_chars.contains(&c) { - break Ok(c); - } + KeyCode::Char(c) if valid_chars.contains(&c) => { + break Ok(c); // Invalid character, continue loop } KeyCode::Enter => { diff --git a/src/utils/mod.rs b/src/utils/mod.rs index f0e0648..8735a39 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -33,7 +33,7 @@ use fuzzy_matcher::{FuzzyMatcher, skim::SkimMatcherV2}; use is_terminal::IsTerminal; use std::borrow::Cow; use std::sync::LazyLock; -use std::{env, path::PathBuf, process}; +use std::{cmp, env, path::PathBuf, process}; use unicode_segmentation::UnicodeSegmentation; pub static CODE_BLOCK_RE: LazyLock = @@ -123,7 +123,7 @@ where Some((v, score)) }) .collect(); - list.sort_unstable_by(|a, b| b.1.cmp(&a.1)); + list.sort_unstable_by_key(|b| cmp::Reverse(b.1)); list.into_iter().map(|(v, _)| v).collect() }