bin: Fix clippy warnings

This commit is contained in:
Erik Kundt
2024-07-09 10:04:37 +02:00
parent 9b9a6427de
commit f3feb9ddd9
3 changed files with 31 additions and 28 deletions
+15 -14
View File
@@ -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(())
}
}
+15 -14
View File
@@ -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(())
}
}
+1
View File
@@ -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,