From 4b5b716ea2a5a5c7a4749b24659454348d9948f1 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Tue, 23 Jul 2024 10:29:09 -0400 Subject: [PATCH] Remove unnecessary derives --- .../activities/community/lock_page.rs | 4 +- crates/apub/src/protocol/activities/mod.rs | 4 +- .../src/protocol/activities/voting/vote.rs | 4 +- crates/db_schema/src/lib.rs | 136 ++---------------- crates/db_views_actor/src/person_view.rs | 4 +- crates/routes/src/feeds.rs | 6 +- crates/utils/src/rate_limit/rate_limiter.rs | 4 +- 7 files changed, 22 insertions(+), 140 deletions(-) diff --git a/crates/apub/src/protocol/activities/community/lock_page.rs b/crates/apub/src/protocol/activities/community/lock_page.rs index 6b615ba10..a08b3c5a2 100644 --- a/crates/apub/src/protocol/activities/community/lock_page.rs +++ b/crates/apub/src/protocol/activities/community/lock_page.rs @@ -13,10 +13,10 @@ use lemmy_api_common::context::LemmyContext; use lemmy_db_schema::{source::community::Community, traits::Crud}; use lemmy_utils::{error::LemmyResult, LemmyErrorType}; use serde::{Deserialize, Serialize}; -use strum::{Display, IntoStaticStr}; +use strum::Display; use url::Url; -#[derive(Clone, Debug, Display, Deserialize, Serialize, IntoStaticStr)] +#[derive(Clone, Debug, Display, Deserialize, Serialize)] pub enum LockType { Lock, } diff --git a/crates/apub/src/protocol/activities/mod.rs b/crates/apub/src/protocol/activities/mod.rs index e3fcf84f3..d1da73a16 100644 --- a/crates/apub/src/protocol/activities/mod.rs +++ b/crates/apub/src/protocol/activities/mod.rs @@ -1,5 +1,5 @@ use serde::{Deserialize, Serialize}; -use strum::{Display, IntoStaticStr}; +use strum::Display; pub mod block; pub mod community; @@ -8,7 +8,7 @@ pub mod deletion; pub mod following; pub mod voting; -#[derive(Clone, Debug, Display, IntoStaticStr, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Clone, Debug, Display, Deserialize, Serialize, PartialEq, Eq)] pub enum CreateOrUpdateType { Create, Update, diff --git a/crates/apub/src/protocol/activities/voting/vote.rs b/crates/apub/src/protocol/activities/voting/vote.rs index 59f4894ef..9fae264a5 100644 --- a/crates/apub/src/protocol/activities/voting/vote.rs +++ b/crates/apub/src/protocol/activities/voting/vote.rs @@ -8,7 +8,7 @@ use activitypub_federation::{config::Data, fetch::object_id::ObjectId}; use lemmy_api_common::context::LemmyContext; use lemmy_utils::error::{LemmyError, LemmyErrorType, LemmyResult}; use serde::{Deserialize, Serialize}; -use strum::{Display, IntoStaticStr}; +use strum::Display; use url::Url; #[derive(Clone, Debug, Deserialize, Serialize)] @@ -22,7 +22,7 @@ pub struct Vote { pub(crate) audience: Option>, } -#[derive(Clone, Debug, Display, IntoStaticStr, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Clone, Debug, Display, Deserialize, Serialize, PartialEq, Eq)] pub enum VoteType { Like, Dislike, diff --git a/crates/db_schema/src/lib.rs b/crates/db_schema/src/lib.rs index c2fb1cbdf..c29ec6443 100644 --- a/crates/db_schema/src/lib.rs +++ b/crates/db_schema/src/lib.rs @@ -48,23 +48,12 @@ pub mod utils; mod schema_setup; use serde::{Deserialize, Serialize}; -use strum::{Display, EnumString, IntoStaticStr}; +use strum::{Display, EnumString}; #[cfg(feature = "full")] use ts_rs::TS; #[derive( - EnumString, - IntoStaticStr, - Display, - Debug, - Serialize, - Deserialize, - Clone, - Copy, - PartialEq, - Eq, - Default, - Hash, + EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, Hash, )] #[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr( @@ -98,19 +87,7 @@ pub enum SortType { Scaled, } -#[derive( - EnumString, - Display, - IntoStaticStr, - Debug, - Serialize, - Deserialize, - Clone, - Copy, - PartialEq, - Eq, - Hash, -)] +#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Hash)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] /// The comment sort types. See here for descriptions: https://join-lemmy.org/docs/en/users/03-votes-and-ranking.html @@ -123,18 +100,7 @@ pub enum CommentSortType { } #[derive( - EnumString, - Display, - IntoStaticStr, - Debug, - Serialize, - Deserialize, - Clone, - Copy, - PartialEq, - Eq, - Default, - Hash, + EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, Hash, )] #[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr( @@ -157,18 +123,7 @@ pub enum ListingType { } #[derive( - EnumString, - Display, - IntoStaticStr, - Debug, - Serialize, - Deserialize, - Clone, - Copy, - PartialEq, - Eq, - Default, - Hash, + EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, Hash, )] #[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr( @@ -189,18 +144,7 @@ pub enum RegistrationMode { } #[derive( - EnumString, - Display, - IntoStaticStr, - Debug, - Serialize, - Deserialize, - Default, - Clone, - Copy, - PartialEq, - Eq, - Hash, + EnumString, Display, Debug, Serialize, Deserialize, Default, Clone, Copy, PartialEq, Eq, Hash, )] #[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr( @@ -220,19 +164,7 @@ pub enum PostListingMode { SmallCard, } -#[derive( - EnumString, - Display, - IntoStaticStr, - Debug, - Serialize, - Deserialize, - Clone, - Copy, - PartialEq, - Eq, - Hash, -)] +#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Hash)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] /// The type of content returned from a search. @@ -245,19 +177,7 @@ pub enum SearchType { Url, } -#[derive( - EnumString, - Display, - IntoStaticStr, - Debug, - PartialEq, - Eq, - Serialize, - Deserialize, - Clone, - Copy, - Hash, -)] +#[derive(EnumString, Display, Debug, PartialEq, Eq, Serialize, Deserialize, Clone, Copy, Hash)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] /// A type / status for a community subscribe. @@ -267,19 +187,7 @@ pub enum SubscribedType { Pending, } -#[derive( - EnumString, - Display, - IntoStaticStr, - Debug, - Serialize, - Deserialize, - Clone, - Copy, - PartialEq, - Eq, - Hash, -)] +#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Hash)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] /// A list of possible types for the various modlog actions. @@ -303,18 +211,7 @@ pub enum ModlogActionType { } #[derive( - EnumString, - Display, - IntoStaticStr, - Debug, - Serialize, - Deserialize, - Clone, - Copy, - Default, - PartialEq, - Eq, - Hash, + EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash, )] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] @@ -328,18 +225,7 @@ pub enum PostFeatureType { } #[derive( - EnumString, - Display, - IntoStaticStr, - Debug, - Serialize, - Deserialize, - Clone, - Copy, - PartialEq, - Eq, - Default, - Hash, + EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, Hash, )] #[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr( diff --git a/crates/db_views_actor/src/person_view.rs b/crates/db_views_actor/src/person_view.rs index 34725022b..7a2edfb44 100644 --- a/crates/db_views_actor/src/person_view.rs +++ b/crates/db_views_actor/src/person_view.rs @@ -27,7 +27,7 @@ use lemmy_db_schema::{ SortType, }; use serde::{Deserialize, Serialize}; -use strum::{Display, EnumString, IntoStaticStr}; +use strum::{Display, EnumString}; enum ListMode { Admins, @@ -35,7 +35,7 @@ enum ListMode { Query(PersonQuery), } -#[derive(EnumString, Display, IntoStaticStr, Debug, Serialize, Deserialize, Clone, Copy)] +#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)] /// The person sort types. Converted automatically from `SortType` enum PersonSortType { New, diff --git a/crates/routes/src/feeds.rs b/crates/routes/src/feeds.rs index 406a7f307..f08f28c4a 100644 --- a/crates/routes/src/feeds.rs +++ b/crates/routes/src/feeds.rs @@ -172,11 +172,7 @@ async fn get_feed_data( let mut channel = Channel { namespaces: RSS_NAMESPACE.clone(), - title: format!( - "{} - {}", - site_view.site.name, - Into::<&'static str>::into(listing_type) - ), + title: format!("{} - {}", site_view.site.name, listing_type), link: context.settings().get_protocol_and_hostname(), items, ..Default::default() diff --git a/crates/utils/src/rate_limit/rate_limiter.rs b/crates/utils/src/rate_limit/rate_limiter.rs index 75f24c9dc..35c95366d 100644 --- a/crates/utils/src/rate_limit/rate_limiter.rs +++ b/crates/utils/src/rate_limit/rate_limiter.rs @@ -6,7 +6,7 @@ use std::{ net::{IpAddr, Ipv4Addr, Ipv6Addr}, time::Instant, }; -use strum::{Display, IntoStaticStr}; +use strum::{AsRefStr, Display}; use tracing::debug; static START_TIME: Lazy = Lazy::new(Instant::now); @@ -66,7 +66,7 @@ impl Bucket { } } -#[derive(Debug, enum_map::Enum, Copy, Clone, Display, IntoStaticStr)] +#[derive(Debug, enum_map::Enum, Copy, Clone, Display, AsRefStr)] pub enum ActionType { Message, Register,