diff --git a/src/main.rs b/src/main.rs index 313f30a..c10155e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,22 +11,22 @@ enum Instruction { F, } -fn parse_orientation(c: char) -> Option { +fn parse_orientation(c: char) -> Result { match c { - 'N' => Some(Orientation::N), - 'E' => Some(Orientation::E), - 'S' => Some(Orientation::S), - 'W' => Some(Orientation::W), - _ => None, + 'N' => Ok(Orientation::N), + 'E' => Ok(Orientation::E), + 'S' => Ok(Orientation::S), + 'W' => Ok(Orientation::W), + _ => Err("Invalid character, does not match any orientations"), } } -fn parse_instruction(c: char) -> Option { +fn parse_instruction(c: char) -> Result { match c { - 'L' => Some(Instruction::L), - 'R' => Some(Instruction::R), - 'F' => Some(Instruction::F), - _ => None, + 'L' => Ok(Instruction::L), + 'R' => Ok(Instruction::R), + 'F' => Ok(Instruction::F), + _ => Err("Invalid character, does not match any instructions"), } }