mirror of
https://github.com/zyllian/classics.git
synced 2025-01-18 03:32:41 -08:00
update WeatherType to use strum internally
This commit is contained in:
parent
76b8339048
commit
b749eb838b
1 changed files with 2 additions and 14 deletions
16
src/level.rs
16
src/level.rs
|
@ -163,7 +163,8 @@ pub struct BlockUpdate {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// weather types for a level
|
/// 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 {
|
pub enum WeatherType {
|
||||||
Sunny,
|
Sunny,
|
||||||
Raining,
|
Raining,
|
||||||
|
@ -195,16 +196,3 @@ impl From<u8> for WeatherType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&str> for WeatherType {
|
|
||||||
type Error = ();
|
|
||||||
|
|
||||||
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
|
||||||
Ok(match value {
|
|
||||||
"sunny" => Self::Sunny,
|
|
||||||
"raining" => Self::Raining,
|
|
||||||
"snowing" => Self::Snowing,
|
|
||||||
_ => return Err(()),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue