diff --git a/src/game.rs b/src/game.rs index ab86c53..bf37718 100644 --- a/src/game.rs +++ b/src/game.rs @@ -9,12 +9,15 @@ use std::str::FromStr; #[derive(Debug, Eq, PartialEq, Copy, Clone)] pub enum RoomFormat {Contiguous, CommaSeparated} +#[derive(Debug)] +pub struct InvalidRoomFormat; + impl RoomFormat { - fn from(str: &str) -> Result { + fn from(str: &str) -> Result { match str { "0" => Ok(RoomFormat::Contiguous), "1" => Ok(RoomFormat::CommaSeparated), - _ => panic!(format!("Invalid room format: {}", str)), + _ => Err(InvalidRoomFormat), } }