#![allow(unused)] use enumex::EnumStr; #[derive(EnumStr, Debug)] enum Animal { Cat, Dog, } #[derive(EnumStr, Debug)] enum Zoo { Cat, Dog, Staff, } impl From for Zoo { fn from(value: Animal) -> Self { Self::from(value.as_str()) } } impl From for Animal { fn from(value: Zoo) -> Self { Self::from(value.as_str()) } } #[cfg(test)] mod tests { use super::*; #[test] fn test_pass() { let cat = Animal::Cat; let cat_zoo = Zoo::from(cat); println!("{cat_zoo:#?}"); let dog_zoo = Zoo::Dog; let dog = Animal::from(dog_zoo); println!("{dog:#?}"); } #[test] #[should_panic] fn test_fail() { let staff_zoo = Zoo::Staff; let staff = Animal::from(staff_zoo); // panic println!("{staff:#?}"); } }