Make eligible enums convertable to static strs (#4915)

* Make eligible enums convertable to static strs

* Run cargo fmt

* Remove unnecessary derives
This commit is contained in:
SleeplessOne1917 2024-07-23 15:05:19 +00:00 committed by GitHub
parent 572a42d880
commit db390a2f3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 400 additions and 388 deletions

762
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -149,8 +149,7 @@ regex = "1.10.4"
once_cell = "1.19.0"
diesel-derive-newtype = "2.1.2"
diesel-derive-enum = { version = "2.1.0", features = ["postgres"] }
strum = "0.26.2"
strum_macros = "0.26.4"
strum = { version = "0.26.3", features = ["derive"] }
itertools = "0.13.0"
futures = "0.3.30"
http = "0.2.12"

View file

@ -31,7 +31,7 @@ serde = { workspace = true }
actix-web = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
strum_macros = { workspace = true }
strum = { workspace = true }
url = { workspace = true }
http = { workspace = true }
futures = { workspace = true }

View file

@ -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_macros::Display;
use strum::Display;
use url::Url;
#[derive(Clone, Debug, Deserialize, Serialize, Display)]
#[derive(Clone, Debug, Display, Deserialize, Serialize)]
pub enum LockType {
Lock,
}

View file

@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};
use strum_macros::Display;
use strum::Display;
pub mod block;
pub mod community;

View file

@ -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_macros::Display;
use strum::Display;
use url::Url;
#[derive(Clone, Debug, Deserialize, Serialize)]

View file

@ -46,7 +46,6 @@ serde = { workspace = true }
serde_with = { workspace = true }
url = { workspace = true }
strum = { workspace = true }
strum_macros = { workspace = true }
serde_json = { workspace = true, optional = true }
activitypub_federation = { workspace = true, optional = true }
lemmy_utils = { workspace = true, optional = true }

View file

@ -48,7 +48,7 @@ pub mod utils;
mod schema_setup;
use serde::{Deserialize, Serialize};
use strum_macros::{Display, EnumString};
use strum::{Display, EnumString};
#[cfg(feature = "full")]
use ts_rs::TS;

View file

@ -33,7 +33,6 @@ serde_with = { workspace = true }
ts-rs = { workspace = true, optional = true }
chrono.workspace = true
strum = { workspace = true }
strum_macros = { workspace = true }
[dev-dependencies]
serial_test = { workspace = true }

View file

@ -27,7 +27,7 @@ use lemmy_db_schema::{
SortType,
};
use serde::{Deserialize, Serialize};
use strum_macros::{Display, EnumString};
use strum::{Display, EnumString};
enum ListMode {
Admins,

View file

@ -64,7 +64,6 @@ actix-web = { workspace = true, optional = true }
anyhow = { workspace = true, optional = true }
reqwest-middleware = { workspace = true, optional = true }
strum = { workspace = true }
strum_macros = { workspace = true }
futures = { workspace = true, optional = true }
diesel = { workspace = true, features = ["chrono"], optional = true }
http = { workspace = true, optional = true }

View file

@ -1,7 +1,7 @@
use cfg_if::cfg_if;
use serde::{Deserialize, Serialize};
use std::fmt::Debug;
use strum_macros::{Display, EnumIter};
use strum::{Display, EnumIter};
#[derive(Display, Debug, Serialize, Deserialize, Clone, PartialEq, Eq, EnumIter, Hash)]
#[cfg_attr(feature = "full", derive(ts_rs::TS))]

View file

@ -6,7 +6,7 @@ use std::{
net::{IpAddr, Ipv4Addr, Ipv6Addr},
time::Instant,
};
use strum_macros::AsRefStr;
use strum::{AsRefStr, Display};
use tracing::debug;
static START_TIME: Lazy<Instant> = Lazy::new(Instant::now);
@ -66,7 +66,7 @@ impl Bucket {
}
}
#[derive(Debug, enum_map::Enum, Copy, Clone, AsRefStr)]
#[derive(Debug, enum_map::Enum, Copy, Clone, Display, AsRefStr)]
pub enum ActionType {
Message,
Register,