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 as term;
use crate::terminal::patch as common; use crate::terminal::patch as common;
use itertools::Itertools as _;
/// List patches. /// List patches.
pub fn run( pub fn run(
filter: Option<&patch::Status>, filter: Option<&patch::Status>,
@ -79,13 +81,14 @@ pub fn run(
is_me.then(by_rev_time).then(by_id) is_me.then(by_rev_time).then(by_id)
}); });
let mut errors = Vec::new(); let (rows, errors): (Vec<_>, Vec<_>) = all
for (id, patch) in &mut all { .iter()
match row(id, patch, repository, profile) { .map(|(id, patch)| {
Ok(r) => table.push(r), row(id, patch, repository, profile).map_err(|e| (patch.title(), id, e.to_string()))
Err(e) => errors.push((patch.title(), id, e.to_string())), })
} .partition_result();
}
table.extend(rows);
table.print(); table.print();
if !errors.is_empty() { if !errors.is_empty() {