error for room format
This commit is contained in:
parent
edbf9575d7
commit
96e9432f06
|
@ -9,12 +9,15 @@ use std::str::FromStr;
|
||||||
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
|
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
|
||||||
pub enum RoomFormat {Contiguous, CommaSeparated}
|
pub enum RoomFormat {Contiguous, CommaSeparated}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct InvalidRoomFormat;
|
||||||
|
|
||||||
impl RoomFormat {
|
impl RoomFormat {
|
||||||
fn from(str: &str) -> Result<RoomFormat, &'static dyn Error> {
|
fn from(str: &str) -> Result<RoomFormat, InvalidRoomFormat> {
|
||||||
match str {
|
match str {
|
||||||
"0" => Ok(RoomFormat::Contiguous),
|
"0" => Ok(RoomFormat::Contiguous),
|
||||||
"1" => Ok(RoomFormat::CommaSeparated),
|
"1" => Ok(RoomFormat::CommaSeparated),
|
||||||
_ => panic!(format!("Invalid room format: {}", str)),
|
_ => Err(InvalidRoomFormat),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue