From b749eb838b85f932371bdddefd396ec03bbebc0c Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 24 Apr 2024 23:32:19 -0700 Subject: [PATCH] update WeatherType to use strum internally --- src/level.rs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/level.rs b/src/level.rs index 1153391..03296e9 100644 --- a/src/level.rs +++ b/src/level.rs @@ -163,7 +163,8 @@ pub struct BlockUpdate { } /// weather types for a level -#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, Serialize, Deserialize, strum::EnumString, strum::IntoStaticStr)] +#[strum(ascii_case_insensitive)] pub enum WeatherType { Sunny, Raining, @@ -195,16 +196,3 @@ impl From for WeatherType { } } } - -impl TryFrom<&str> for WeatherType { - type Error = (); - - fn try_from(value: &str) -> Result { - Ok(match value { - "sunny" => Self::Sunny, - "raining" => Self::Raining, - "snowing" => Self::Snowing, - _ => return Err(()), - }) - } -}