From c1143ee396646bf71c550c06cfb87fdeb629e241 Mon Sep 17 00:00:00 2001 From: mhart Date: Sun, 11 Oct 2020 18:27:39 +0200 Subject: [PATCH] Add parse_orientation() This function parse a char and return the matching direction or None --- src/main.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.rs b/src/main.rs index 409075e..4052eaf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,6 +11,16 @@ enum Instruction { F, } +fn parse_orientation(c: char) -> Option { + match c { + 'N' => Some(Orientation::N), + 'E' => Some(Orientation::E), + 'S' => Some(Orientation::S), + 'W' => Some(Orientation::W), + _ => None, + } +} + fn main() { let file_data = include_str!("../two_robots.txt"); }