From 1c3de60bb9117db558cc86722101594b6c45bca2 Mon Sep 17 00:00:00 2001 From: "Dhanji R. Prasanna" Date: Sun, 11 Jan 2026 16:18:48 +0530 Subject: [PATCH] refactor(core): simplify truncate_line() by merging identical branches The function had two branches that both returned line.to_string(): - when !should_truncate - when line.chars().count() <= max_width Merged into a single condition. Also updated format! to use inline variable syntax per clippy suggestion. Agent: fowler --- crates/g3-core/src/streaming.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/g3-core/src/streaming.rs b/crates/g3-core/src/streaming.rs index 7428341..fa4211c 100644 --- a/crates/g3-core/src/streaming.rs +++ b/crates/g3-core/src/streaming.rs @@ -235,13 +235,11 @@ pub fn truncate_for_display(s: &str, max_len: usize) -> String { /// Truncate a line for tool output display pub fn truncate_line(line: &str, max_width: usize, should_truncate: bool) -> String { - if !should_truncate { - line.to_string() - } else if line.chars().count() <= max_width { + if !should_truncate || line.chars().count() <= max_width { line.to_string() } else { let truncated: String = line.chars().take(max_width.saturating_sub(3)).collect(); - format!("{}...", truncated) + format!("{truncated}...") } }