diff --git a/bin/cob/issue.rs b/bin/cob/issue.rs index 0323697f..f27b1f3b 100644 --- a/bin/cob/issue.rs +++ b/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(()) } } diff --git a/bin/cob/patch.rs b/bin/cob/patch.rs index e7bd1437..7a0fde31 100644 --- a/bin/cob/patch.rs +++ b/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(()) } } diff --git a/bin/commands/inbox/select.rs b/bin/commands/inbox/select.rs index d4fc60f5..1fae687b 100644 --- a/bin/commands/inbox/select.rs +++ b/bin/commands/inbox/select.rs @@ -43,6 +43,7 @@ use super::common::{Mode, RepositoryMode}; type Selection = tui::Selection; +#[allow(dead_code)] pub struct Context { pub profile: Profile, pub repository: Repository,