From b162d1dbb00b7f25739471f73307704a4476ddbf Mon Sep 17 00:00:00 2001 From: Orchaldir Date: Sun, 10 Sep 2023 11:24:17 +0200 Subject: [PATCH] [#36] Improve EarShape --- .../model/character/appearance/ear/shape.rs | 40 +------------------ 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/rpg_tools_core/src/model/character/appearance/ear/shape.rs b/rpg_tools_core/src/model/character/appearance/ear/shape.rs index 6bbf8123..34c032d7 100644 --- a/rpg_tools_core/src/model/character/appearance/ear/shape.rs +++ b/rpg_tools_core/src/model/character/appearance/ear/shape.rs @@ -1,11 +1,10 @@ use crate::ui::{UiVisitor, UI}; +use macro_convert::Convert; use macro_ui::ui; use serde::{Deserialize, Serialize}; -use std::fmt; -use EarShape::*; /// How many ears does the character have? -#[derive(ui, Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Convert, ui, Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum EarShape { /// Like an elf's ears. Pointed, @@ -13,38 +12,3 @@ pub enum EarShape { #[default] Square, } - -impl EarShape { - pub fn get_all() -> Vec { - vec![Pointed, Round, Square] - } -} - -impl fmt::Display for EarShape { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{:?}", self) - } -} - -impl From<&str> for EarShape { - fn from(shape: &str) -> Self { - match shape { - "Pointed" => Pointed, - "Round" => Round, - _ => Square, - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_conversion() { - for shape in EarShape::get_all() { - let string = shape.to_string(); - assert_eq!(shape, EarShape::from(&*string)); - } - } -}