cli/patch: Replace manual iterator partitioning with Itertools::partition_result()

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2025-09-07 13:28:30 +02:00 committed by Lorenz Leutgeb
parent 3f489354b6
commit 370ae3643a
1 changed files with 10 additions and 7 deletions

View File

@ -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() {