Remove unnecessary derives

This commit is contained in:
SleeplessOne1917 2024-07-23 10:29:09 -04:00
parent 8d1b589d42
commit 4b5b716ea2
7 changed files with 22 additions and 140 deletions

View File

@ -13,10 +13,10 @@ use lemmy_api_common::context::LemmyContext;
use lemmy_db_schema::{source::community::Community, traits::Crud}; use lemmy_db_schema::{source::community::Community, traits::Crud};
use lemmy_utils::{error::LemmyResult, LemmyErrorType}; use lemmy_utils::{error::LemmyResult, LemmyErrorType};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use strum::{Display, IntoStaticStr}; use strum::Display;
use url::Url; use url::Url;
#[derive(Clone, Debug, Display, Deserialize, Serialize, IntoStaticStr)] #[derive(Clone, Debug, Display, Deserialize, Serialize)]
pub enum LockType { pub enum LockType {
Lock, Lock,
} }

View File

@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use strum::{Display, IntoStaticStr}; use strum::Display;
pub mod block; pub mod block;
pub mod community; pub mod community;
@ -8,7 +8,7 @@ pub mod deletion;
pub mod following; pub mod following;
pub mod voting; pub mod voting;
#[derive(Clone, Debug, Display, IntoStaticStr, Deserialize, Serialize, PartialEq, Eq)] #[derive(Clone, Debug, Display, Deserialize, Serialize, PartialEq, Eq)]
pub enum CreateOrUpdateType { pub enum CreateOrUpdateType {
Create, Create,
Update, Update,

View File

@ -8,7 +8,7 @@ use activitypub_federation::{config::Data, fetch::object_id::ObjectId};
use lemmy_api_common::context::LemmyContext; use lemmy_api_common::context::LemmyContext;
use lemmy_utils::error::{LemmyError, LemmyErrorType, LemmyResult}; use lemmy_utils::error::{LemmyError, LemmyErrorType, LemmyResult};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use strum::{Display, IntoStaticStr}; use strum::Display;
use url::Url; use url::Url;
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
@ -22,7 +22,7 @@ pub struct Vote {
pub(crate) audience: Option<ObjectId<ApubCommunity>>, pub(crate) audience: Option<ObjectId<ApubCommunity>>,
} }
#[derive(Clone, Debug, Display, IntoStaticStr, Deserialize, Serialize, PartialEq, Eq)] #[derive(Clone, Debug, Display, Deserialize, Serialize, PartialEq, Eq)]
pub enum VoteType { pub enum VoteType {
Like, Like,
Dislike, Dislike,

View File

@ -48,23 +48,12 @@ pub mod utils;
mod schema_setup; mod schema_setup;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use strum::{Display, EnumString, IntoStaticStr}; use strum::{Display, EnumString};
#[cfg(feature = "full")] #[cfg(feature = "full")]
use ts_rs::TS; use ts_rs::TS;
#[derive( #[derive(
EnumString, EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, Hash,
IntoStaticStr,
Display,
Debug,
Serialize,
Deserialize,
Clone,
Copy,
PartialEq,
Eq,
Default,
Hash,
)] )]
#[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr(feature = "full", derive(DbEnum, TS))]
#[cfg_attr( #[cfg_attr(
@ -98,19 +87,7 @@ pub enum SortType {
Scaled, Scaled,
} }
#[derive( #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Hash)]
EnumString,
Display,
IntoStaticStr,
Debug,
Serialize,
Deserialize,
Clone,
Copy,
PartialEq,
Eq,
Hash,
)]
#[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", derive(TS))]
#[cfg_attr(feature = "full", ts(export))] #[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 /// 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( #[derive(
EnumString, EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, Hash,
Display,
IntoStaticStr,
Debug,
Serialize,
Deserialize,
Clone,
Copy,
PartialEq,
Eq,
Default,
Hash,
)] )]
#[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr(feature = "full", derive(DbEnum, TS))]
#[cfg_attr( #[cfg_attr(
@ -157,18 +123,7 @@ pub enum ListingType {
} }
#[derive( #[derive(
EnumString, EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, Hash,
Display,
IntoStaticStr,
Debug,
Serialize,
Deserialize,
Clone,
Copy,
PartialEq,
Eq,
Default,
Hash,
)] )]
#[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr(feature = "full", derive(DbEnum, TS))]
#[cfg_attr( #[cfg_attr(
@ -189,18 +144,7 @@ pub enum RegistrationMode {
} }
#[derive( #[derive(
EnumString, EnumString, Display, Debug, Serialize, Deserialize, Default, Clone, Copy, PartialEq, Eq, Hash,
Display,
IntoStaticStr,
Debug,
Serialize,
Deserialize,
Default,
Clone,
Copy,
PartialEq,
Eq,
Hash,
)] )]
#[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr(feature = "full", derive(DbEnum, TS))]
#[cfg_attr( #[cfg_attr(
@ -220,19 +164,7 @@ pub enum PostListingMode {
SmallCard, SmallCard,
} }
#[derive( #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Hash)]
EnumString,
Display,
IntoStaticStr,
Debug,
Serialize,
Deserialize,
Clone,
Copy,
PartialEq,
Eq,
Hash,
)]
#[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", derive(TS))]
#[cfg_attr(feature = "full", ts(export))] #[cfg_attr(feature = "full", ts(export))]
/// The type of content returned from a search. /// The type of content returned from a search.
@ -245,19 +177,7 @@ pub enum SearchType {
Url, Url,
} }
#[derive( #[derive(EnumString, Display, Debug, PartialEq, Eq, Serialize, Deserialize, Clone, Copy, Hash)]
EnumString,
Display,
IntoStaticStr,
Debug,
PartialEq,
Eq,
Serialize,
Deserialize,
Clone,
Copy,
Hash,
)]
#[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", derive(TS))]
#[cfg_attr(feature = "full", ts(export))] #[cfg_attr(feature = "full", ts(export))]
/// A type / status for a community subscribe. /// A type / status for a community subscribe.
@ -267,19 +187,7 @@ pub enum SubscribedType {
Pending, Pending,
} }
#[derive( #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Hash)]
EnumString,
Display,
IntoStaticStr,
Debug,
Serialize,
Deserialize,
Clone,
Copy,
PartialEq,
Eq,
Hash,
)]
#[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", derive(TS))]
#[cfg_attr(feature = "full", ts(export))] #[cfg_attr(feature = "full", ts(export))]
/// A list of possible types for the various modlog actions. /// A list of possible types for the various modlog actions.
@ -303,18 +211,7 @@ pub enum ModlogActionType {
} }
#[derive( #[derive(
EnumString, EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash,
Display,
IntoStaticStr,
Debug,
Serialize,
Deserialize,
Clone,
Copy,
Default,
PartialEq,
Eq,
Hash,
)] )]
#[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", derive(TS))]
#[cfg_attr(feature = "full", ts(export))] #[cfg_attr(feature = "full", ts(export))]
@ -328,18 +225,7 @@ pub enum PostFeatureType {
} }
#[derive( #[derive(
EnumString, EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, Hash,
Display,
IntoStaticStr,
Debug,
Serialize,
Deserialize,
Clone,
Copy,
PartialEq,
Eq,
Default,
Hash,
)] )]
#[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr(feature = "full", derive(DbEnum, TS))]
#[cfg_attr( #[cfg_attr(

View File

@ -27,7 +27,7 @@ use lemmy_db_schema::{
SortType, SortType,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use strum::{Display, EnumString, IntoStaticStr}; use strum::{Display, EnumString};
enum ListMode { enum ListMode {
Admins, Admins,
@ -35,7 +35,7 @@ enum ListMode {
Query(PersonQuery), 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` /// The person sort types. Converted automatically from `SortType`
enum PersonSortType { enum PersonSortType {
New, New,

View File

@ -172,11 +172,7 @@ async fn get_feed_data(
let mut channel = Channel { let mut channel = Channel {
namespaces: RSS_NAMESPACE.clone(), namespaces: RSS_NAMESPACE.clone(),
title: format!( title: format!("{} - {}", site_view.site.name, listing_type),
"{} - {}",
site_view.site.name,
Into::<&'static str>::into(listing_type)
),
link: context.settings().get_protocol_and_hostname(), link: context.settings().get_protocol_and_hostname(),
items, items,
..Default::default() ..Default::default()

View File

@ -6,7 +6,7 @@ use std::{
net::{IpAddr, Ipv4Addr, Ipv6Addr}, net::{IpAddr, Ipv4Addr, Ipv6Addr},
time::Instant, time::Instant,
}; };
use strum::{Display, IntoStaticStr}; use strum::{AsRefStr, Display};
use tracing::debug; use tracing::debug;
static START_TIME: Lazy<Instant> = Lazy::new(Instant::now); static START_TIME: Lazy<Instant> = 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 { pub enum ActionType {
Message, Message,
Register, Register,