Radish alpha
r
rad:z39mP9rQAaGmERfUMPULfPUi473tY
Radicle terminal user interface
Radicle
Git
Fix clippy warnings
Merged did:key:z6MkswQE...2C1V opened 1 year ago
5 files changed +33 -30 4af18a47 f3feb9dd
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,
modified src/ui/ext.rs
@@ -129,7 +129,7 @@ pub struct FooterBlock {
    /// Type of the border. The default is plain lines but one can choose to have rounded corners
    /// or doubled lines instead.
    border_type: BorderType,
-
    ///
+
    /// Type of the footer block. The default is single.
    block_type: FooterBlockType,
    /// Widget style
    style: Style,
modified src/ui/widget/list.rs
@@ -28,7 +28,7 @@ pub trait ToRow<const W: usize> {
    fn to_row(&self) -> [Cell; W];
}

-
/// Needs to be implemented for items that are supposed to be rendered in tables.
+
/// Needs to be implemented for items that are supposed to be rendered in trees.
pub trait ToTree<Id>
where
    Id: ToString,