From 370ae3643a57f20a88aff512db454f12ddefd258 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 7 Sep 2025 13:28:30 +0200 Subject: [PATCH] cli/patch: Replace manual iterator partitioning with Itertools::partition_result() Signed-off-by: Matthias Beyer --- crates/radicle-cli/src/commands/patch/list.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/radicle-cli/src/commands/patch/list.rs b/crates/radicle-cli/src/commands/patch/list.rs index fd2c4584..ff9f2d45 100644 --- a/crates/radicle-cli/src/commands/patch/list.rs +++ b/crates/radicle-cli/src/commands/patch/list.rs @@ -14,6 +14,8 @@ use term::Element as _; use crate::terminal as term; use crate::terminal::patch as common; +use itertools::Itertools as _; + /// List patches. pub fn run( filter: Option<&patch::Status>, @@ -79,13 +81,14 @@ pub fn run( is_me.then(by_rev_time).then(by_id) }); - let mut errors = Vec::new(); - for (id, patch) in &mut all { - match row(id, patch, repository, profile) { - Ok(r) => table.push(r), - Err(e) => errors.push((patch.title(), id, e.to_string())), - } - } + let (rows, errors): (Vec<_>, Vec<_>) = all + .iter() + .map(|(id, patch)| { + row(id, patch, repository, profile).map_err(|e| (patch.title(), id, e.to_string())) + }) + .partition_result(); + + table.extend(rows); table.print(); if !errors.is_empty() {