From 30cd8cd119e61586fbe10b7df37a5cbaa77a52ce Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 22 Mar 2026 16:04:34 -0400 Subject: [PATCH] to_str impls for two enums --- .../src/common/artcraft_credits_pack_slug.rs | 35 +++++++++++++++++++ .../src/common/artcraft_subscription_slug.rs | 29 +++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/crates/schema/public/enums_api/src/common/artcraft_credits_pack_slug.rs b/crates/schema/public/enums_api/src/common/artcraft_credits_pack_slug.rs index 3f3d8e7acc..ee8f5c5060 100644 --- a/crates/schema/public/enums_api/src/common/artcraft_credits_pack_slug.rs +++ b/crates/schema/public/enums_api/src/common/artcraft_credits_pack_slug.rs @@ -21,6 +21,19 @@ pub enum ArtcraftCreditsPackSlug { Artcraft50000, } +impl ArtcraftCreditsPackSlug { + pub const fn to_str(&self) -> &'static str { + match self { + Self::Artcraft1000 => "artcraft_1000", + Self::Artcraft2500 => "artcraft_2500", + Self::Artcraft5000 => "artcraft_5000", + Self::Artcraft10000 => "artcraft_10000", + Self::Artcraft25000 => "artcraft_25000", + Self::Artcraft50000 => "artcraft_50000", + } + } +} + #[cfg(test)] mod tests { use super::ArtcraftCreditsPackSlug; @@ -56,6 +69,28 @@ mod tests { } } + mod to_str_checks { + use super::*; + + #[test] + fn to_str() { + assert_eq!(ArtcraftCreditsPackSlug::Artcraft1000.to_str(), "artcraft_1000"); + assert_eq!(ArtcraftCreditsPackSlug::Artcraft2500.to_str(), "artcraft_2500"); + assert_eq!(ArtcraftCreditsPackSlug::Artcraft5000.to_str(), "artcraft_5000"); + assert_eq!(ArtcraftCreditsPackSlug::Artcraft10000.to_str(), "artcraft_10000"); + assert_eq!(ArtcraftCreditsPackSlug::Artcraft25000.to_str(), "artcraft_25000"); + assert_eq!(ArtcraftCreditsPackSlug::Artcraft50000.to_str(), "artcraft_50000"); + } + + #[test] + fn to_str_matches_serde() { + for variant in ArtcraftCreditsPackSlug::iter() { + let serde_str = serde_json::to_string(&variant).unwrap().replace('"', ""); + assert_eq!(variant.to_str(), serde_str); + } + } + } + mod mechanical_checks { use super::*; diff --git a/crates/schema/public/enums_api/src/common/artcraft_subscription_slug.rs b/crates/schema/public/enums_api/src/common/artcraft_subscription_slug.rs index e4587ac0e4..e61b942446 100644 --- a/crates/schema/public/enums_api/src/common/artcraft_subscription_slug.rs +++ b/crates/schema/public/enums_api/src/common/artcraft_subscription_slug.rs @@ -12,6 +12,16 @@ pub enum ArtcraftSubscriptionSlug { ArtcraftMax, } +impl ArtcraftSubscriptionSlug { + pub const fn to_str(&self) -> &'static str { + match self { + Self::ArtcraftBasic => "artcraft_basic", + Self::ArtcraftPro => "artcraft_pro", + Self::ArtcraftMax => "artcraft_max", + } + } +} + #[cfg(test)] mod tests { use super::ArtcraftSubscriptionSlug; @@ -41,6 +51,25 @@ mod tests { } } + mod to_str_checks { + use super::*; + + #[test] + fn to_str() { + assert_eq!(ArtcraftSubscriptionSlug::ArtcraftBasic.to_str(), "artcraft_basic"); + assert_eq!(ArtcraftSubscriptionSlug::ArtcraftPro.to_str(), "artcraft_pro"); + assert_eq!(ArtcraftSubscriptionSlug::ArtcraftMax.to_str(), "artcraft_max"); + } + + #[test] + fn to_str_matches_serde() { + for variant in ArtcraftSubscriptionSlug::iter() { + let serde_str = serde_json::to_string(&variant).unwrap().replace('"', ""); + assert_eq!(variant.to_str(), serde_str); + } + } + } + mod mechanical_checks { use super::*;