Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli/patch: Replace manual iterator partitioning with Itertools::partition_result()
Matthias Beyer committed 7 months ago
commit 69daf9b93e80a1ff2f708273804d0c39d25ff484
parent c3d94113f3403c462203989ab92a845f7cc0c705
1 file changed +10 -7
modified 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() {