Skip to content

Commit

Permalink
Fix clippy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
DanNixon committed Jan 6, 2025
1 parent 37265a9 commit 51db9b3
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/source/github_authed_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use anyhow::Result;
use async_trait::async_trait;
use octocrab::Octocrab;
use serde::{Deserialize, Serialize};
use std::fmt::Display;

#[derive(Debug, Deserialize)]
pub(crate) struct GithubAuthenticatedUser {
Expand Down Expand Up @@ -73,23 +74,25 @@ struct Visibilities {
visibility: Vec<Visibility>,
}

impl ToString for Visibilities {
fn to_string(&self) -> String {
impl Display for Visibilities {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.visibility.len() {
1 => serde_variant::to_variant_name(&self.visibility[0])
.unwrap()
.to_string(),
1 => write!(
f,
"{}",
serde_variant::to_variant_name(&self.visibility[0]).unwrap()
),
2 => {
if self.visibility.contains(&Visibility::Private)
&& (self.visibility.contains(&Visibility::Private)
|| self.visibility.contains(&Visibility::Internal))
{
"both".to_string()
write!(f, "both")
} else {
"".to_string()
write!(f, "")
}
}
_ => "".to_string(),
_ => write!(f, ""),
}
}
}
Expand All @@ -107,13 +110,15 @@ struct Affiliations {
affiliation: Vec<Affiliation>,
}

impl ToString for Affiliations {
fn to_string(&self) -> String {
self.affiliation
impl Display for Affiliations {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let s = self
.affiliation
.iter()
.map(|i| serde_variant::to_variant_name(i).unwrap())
.collect::<Vec<&str>>()
.join(",")
.join(",");
write!(f, "{}", s)
}
}

Expand Down

0 comments on commit 51db9b3

Please sign in to comment.