Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
bin: Fix clippy warnings
Erik Kundt committed 1 year ago
commit f3feb9ddd9ecdba3c088e6c562d0376e2f4192d3
parent 9b9a6427de7c675b49f5014c0e8f7e22880a0526
3 files changed +31 -28
modified bin/cob/issue.rs
@@ -1,3 +1,6 @@
+
use std::fmt;
+
use std::fmt::Write as _;
+

use anyhow::Result;

use radicle::cob::issue::{Issue, IssueId};
@@ -42,34 +45,32 @@ impl Filter {
    }
}

-
impl ToString for Filter {
-
    fn to_string(&self) -> String {
-
        let mut filter = String::new();
-

+
impl fmt::Display for Filter {
+
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        if let Some(state) = &self.state {
-
            filter.push_str(&format!("is:{}", state));
-
            filter.push(' ');
+
            write!(f, "is:{}", state)?;
+
            f.write_char(' ')?;
        }
        if self.assigned {
-
            filter.push_str("is:assigned");
-
            filter.push(' ');
+
            f.write_str("is:assigned")?;
+
            f.write_char(' ')?;
        }
        if !self.assignees.is_empty() {
-
            filter.push_str("assignees:");
-
            filter.push('[');
+
            f.write_str("assignees:")?;
+
            f.write_char('[')?;

            let mut assignees = self.assignees.iter().peekable();
            while let Some(assignee) = assignees.next() {
-
                filter.push_str(&assignee.encode());
+
                f.write_str(&assignee.encode())?;

                if assignees.peek().is_some() {
-
                    filter.push(',');
+
                    f.write_char(',')?;
                }
            }
-
            filter.push(']');
+
            f.write_char(']')?;
        }

-
        filter
+
        Ok(())
    }
}

modified bin/cob/patch.rs
@@ -1,3 +1,6 @@
+
use std::fmt;
+
use std::fmt::Write as _;
+

use anyhow::Result;

use radicle::cob::patch::{Patch, PatchId};
@@ -41,34 +44,32 @@ impl Filter {
    }
}

-
impl ToString for Filter {
-
    fn to_string(&self) -> String {
-
        let mut filter = String::new();
-

+
impl fmt::Display for Filter {
+
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        if let Some(state) = &self.status {
-
            filter.push_str(&format!("is:{}", state));
-
            filter.push(' ');
+
            write!(f, "is:{}", state)?;
+
            f.write_char(' ')?;
        }
        if self.authored {
-
            filter.push_str("is:authored");
-
            filter.push(' ');
+
            f.write_str("is:authored")?;
+
            f.write_char(' ')?;
        }
        if !self.authors.is_empty() {
-
            filter.push_str("authors:");
-
            filter.push('[');
+
            f.write_str("authors:")?;
+
            f.write_char('[')?;

            let mut authors = self.authors.iter().peekable();
            while let Some(author) = authors.next() {
-
                filter.push_str(&author.encode());
+
                f.write_str(&author.encode())?;

                if authors.peek().is_some() {
-
                    filter.push(',');
+
                    f.write_char(',')?;
                }
            }
-
            filter.push(']');
+
            f.write_char(']')?;
        }

-
        filter
+
        Ok(())
    }
}

modified bin/commands/inbox/select.rs
@@ -43,6 +43,7 @@ use super::common::{Mode, RepositoryMode};

type Selection = tui::Selection<NotificationId>;

+
#[allow(dead_code)]
pub struct Context {
    pub profile: Profile,
    pub repository: Repository,