Radish alpha
r
rad:z39mP9rQAaGmERfUMPULfPUi473tY
Radicle terminal user interface
Radicle
Git
bin/ui: Simplify impl of ui::format::assignees()
Matthias Beyer committed 4 months ago
commit d52dca76b60490027ac059eb6b0706c5282f8f1c
parent 8aeffe6
1 file changed +7 -13
modified bin/ui/format.rs
@@ -76,17 +76,11 @@ pub fn author(did: &Did, alias: &Option<Alias>, is_you: bool) -> String {
}

pub fn assignees(assignees: &[(Option<PublicKey>, Option<Alias>, bool)]) -> String {
-
    let mut output = String::new();
-
    let mut assignees = assignees.iter().peekable();
-

-
    while let Some((assignee, alias, is_you)) = assignees.next() {
-
        if let Some(assignee) = assignee {
-
            output.push_str(&self::author(&Did::from(assignee), alias, *is_you));
-
        }
-

-
        if assignees.peek().is_some() {
-
            output.push(',');
-
        }
-
    }
-
    output
+
    assignees
+
        .iter()
+
        .flat_map(|(assignee, alias, is_you)| {
+
            assignee.map(|a| self::author(&Did::from(a), alias, *is_you))
+
        })
+
        .collect::<Vec<_>>()
+
        .join(",")
}