From 3749f7204800ef52f2babf6f74a2d55c604adf1b Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Mon, 11 Nov 2024 01:21:18 +0100 Subject: [PATCH] refactor(main): optimize feedback for (( command --- src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 794ae4c..16e3f98 100644 --- a/src/main.rs +++ b/src/main.rs @@ -656,16 +656,16 @@ async fn main() -> Result<()> { } } let (label, times) = tasks.times_tracked(); - let mut times = times.peekable(); + let vec = times.rev().take(max).collect_vec(); println!("{}\n{}", - if times.peek().is_some() { + if vec.is_empty() { + label + } else { format!("{} {}", if max == usize::MAX { "All".to_string() } else { format!("Latest {max} entries of") }, label) - } else { - label }, - times.rev().take(max).collect_vec().iter().rev().join("\n")); + vec.iter().rev().join("\n")); } else if let Ok(key) = PublicKey::parse(arg) { // TODO also match name let (label, mut times) = tasks.times_tracked_for(&key); println!("{}\n{}", label.italic(),