Skip to content

Commit

Permalink
#: Add enum item function
Browse files Browse the repository at this point in the history
  • Loading branch information
zdu-strong committed Jan 29, 2025
1 parent d14e1d0 commit 81b66e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ edition = "2021"
[dependencies]
tokio = { version = "1.33.0", features = ["full"] }
lazy_static = "1.4.0"
serde_json = "1.0.117"
serde_json = "1.0.138"
serde = { version = "1.0.203", features = ["derive"] }
futures = "0.3.30"
uuid = { version = "1.8.0", features = ["v4"] }
chrono = { version = "0.4.39", features = ["serde"] }
async-recursion = "1.0.5"
strum = "0.26"
strum_macros = "0.26"

[profile.dev]
overflow-checks = true
Expand Down
8 changes: 4 additions & 4 deletions rust/src/enumable/animal_enum.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use serde::Deserialize;
use serde::Serialize;
use strum::IntoEnumIterator;
use strum_macros::EnumIter;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, EnumIter)]
#[serde(rename_all = "camelCase")]
pub enum AnimalEnum {
Tiger,
Expand All @@ -10,11 +12,9 @@ pub enum AnimalEnum {

impl AnimalEnum {
pub fn values() -> Vec<AnimalEnum> {
return [AnimalEnum::Tiger, AnimalEnum::Dog].to_vec();
AnimalEnum::iter().collect::<Vec<_>>()
}
}

impl AnimalEnum {
pub fn name(&mut self) -> String {
return match self {
AnimalEnum::Tiger => "Tiger".to_string(),
Expand Down

0 comments on commit 81b66e3

Please sign in to comment.