From 34edf573d7198766c5c9aaf782287e24a720b3fb Mon Sep 17 00:00:00 2001 From: pap Date: Wed, 30 Jul 2025 18:06:11 +0100 Subject: [PATCH] linter --- codex-rs/tui/src/app.rs | 12 +++++++++--- codex-rs/tui/src/bottom_pane/model_selection_view.rs | 2 +- codex-rs/tui/src/chatwidget.rs | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs index 56f185486e..65e41af94c 100644 --- a/codex-rs/tui/src/app.rs +++ b/codex-rs/tui/src/app.rs @@ -51,9 +51,15 @@ fn strip_surrounding_quotes(s: &str) -> String { return trimmed.to_string(); } - let mut chars = trimmed.chars(); - let first = chars.next().unwrap(); - let last = trimmed.chars().last().unwrap(); + // Safely obtain the first and last characters without unwraps. + let (first, last) = { + let mut chs = trimmed.chars(); + match (chs.next(), chs.next_back()) { + (Some(f), Some(l)) => (f, l), + (Some(f), None) => (f, f), + _ => return trimmed.to_string(), + } + }; let is_valid_quote = match first { '"' | '\'' | '“' | '‘' => first == last, diff --git a/codex-rs/tui/src/bottom_pane/model_selection_view.rs b/codex-rs/tui/src/bottom_pane/model_selection_view.rs index cf40dba68e..e7f1c12ce6 100644 --- a/codex-rs/tui/src/bottom_pane/model_selection_view.rs +++ b/codex-rs/tui/src/bottom_pane/model_selection_view.rs @@ -203,7 +203,7 @@ fn fuzzy_match(haystack: &str, needle: &str) -> Option<(Vec, i32)> { for ch in n_lower.chars() { let mut found = None; - while let Some((i, hc)) = h_iter.next() { + for (i, hc) in h_iter.by_ref() { if hc == ch { found = Some(i); break; diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index 65609c7863..24ab2e9bb9 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -531,7 +531,7 @@ impl ChatWidget<'_> { // Emit a lightweight event in the conversation log so the change is visible. if changed { self.conversation_history - .add_background_event(format!("Set model to {}.", model)); + .add_background_event(format!("Set model to {model}.")); self.emit_last_history_entry(); }