From 05d11426a8e60fa060733eb8ae7843bc2ae9725c Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 10 Jun 2024 15:28:36 +0200 Subject: apply many clippy issue --- common/src/helpers.rs | 10 ++++++++-- common/src/lib.rs | 10 +++++----- common/src/user.rs | 12 ++++++------ 3 files changed, 19 insertions(+), 13 deletions(-) (limited to 'common/src') diff --git a/common/src/helpers.rs b/common/src/helpers.rs index 92595e0..54f5479 100644 --- a/common/src/helpers.rs +++ b/common/src/helpers.rs @@ -5,15 +5,21 @@ */ use std::ops::Deref; -#[derive(PartialEq, PartialOrd)] +#[derive(PartialEq)] pub struct SortAnyway(pub T); impl Eq for SortAnyway { fn assert_receiver_is_total_eq(&self) {} } +#[allow(clippy::non_canonical_partial_ord_impl)] +impl PartialOrd for SortAnyway { + fn partial_cmp(&self, other: &Self) -> Option { + self.0.partial_cmp(&other.0) + } +} impl Ord for SortAnyway { fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.partial_cmp(&other).unwrap() + self.partial_cmp(other).unwrap() } } diff --git a/common/src/lib.rs b/common/src/lib.rs index d06c40c..7403347 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -3,6 +3,7 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2024 metamuffin */ +#![allow(clippy::needless_borrows_for_generic_args)] pub mod config; pub mod helpers; pub mod r#impl; @@ -282,17 +283,16 @@ impl TraktKind { } } } -impl ToString for TraktKind { - fn to_string(&self) -> String { - match self { +impl Display for TraktKind { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(match self { TraktKind::Movie => "Movie", TraktKind::Show => "Show", TraktKind::Season => "Season", TraktKind::Episode => "Episode", TraktKind::Person => "Person", TraktKind::User => "User", - } - .to_string() + }) } } impl Display for ObjectIds { diff --git a/common/src/user.rs b/common/src/user.rs index 5f2b0e4..1a527b9 100644 --- a/common/src/user.rs +++ b/common/src/user.rs @@ -129,19 +129,19 @@ impl UserPermission { impl Display for UserPermission { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(&match self { - UserPermission::ManageSelf => format!("manage self (password, display name, etc.)"), - UserPermission::FederatedContent => format!("access to federated content"), - UserPermission::Admin => format!("administrative rights"), + UserPermission::ManageSelf => "manage self (password, display name, etc.)".to_string(), + UserPermission::FederatedContent => "access to federated content".to_string(), + UserPermission::Admin => "administrative rights".to_string(), UserPermission::StreamFormat(StreamFormat::Original) => { - format!("downloading the original media") + "downloading the original media".to_string() } UserPermission::StreamFormat(StreamFormat::Matroska) => { - format!("downloading a remuxed WebM/Matroska version of the media ") + "downloading a remuxed WebM/Matroska version of the media ".to_string() } UserPermission::StreamFormat(x) => { format!("downloading media via {x:?}") } - UserPermission::Transcode => format!("transcoding"), + UserPermission::Transcode => "transcoding".to_string(), // UserPermission::ManageUsers => format!("management of all users"), // UserPermission::GenerateInvite => format!("inviting new users"), UserPermission::AccessNode(s) => format!("access to library node {s:?}"), -- cgit v1.2.3-70-g09d2