diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-10 15:28:36 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-10 15:28:36 +0200 |
commit | 05d11426a8e60fa060733eb8ae7843bc2ae9725c (patch) | |
tree | 57cfad9cedf1eb50de193f1657b42234745c044e /common/src | |
parent | c0365c8c64f403fd9ee75c0db1a9ed6134633e8f (diff) | |
download | jellything-05d11426a8e60fa060733eb8ae7843bc2ae9725c.tar jellything-05d11426a8e60fa060733eb8ae7843bc2ae9725c.tar.bz2 jellything-05d11426a8e60fa060733eb8ae7843bc2ae9725c.tar.zst |
apply many clippy issue
Diffstat (limited to 'common/src')
-rw-r--r-- | common/src/helpers.rs | 10 | ||||
-rw-r--r-- | common/src/lib.rs | 10 | ||||
-rw-r--r-- | common/src/user.rs | 12 |
3 files changed, 19 insertions, 13 deletions
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<T>(pub T); impl<T: PartialEq> Eq for SortAnyway<T> { fn assert_receiver_is_total_eq(&self) {} } +#[allow(clippy::non_canonical_partial_ord_impl)] +impl<T: PartialOrd> PartialOrd for SortAnyway<T> { + fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { + self.0.partial_cmp(&other.0) + } +} impl<T: PartialOrd> Ord for SortAnyway<T> { 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 <metamuffin.org> */ +#![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:?}"), |