Add parse_orientation()

This function parse a char and return the matching direction or None
This commit is contained in:
mhart 2020-10-11 18:27:39 +02:00
parent dcbc5aa74c
commit c1143ee396
1 changed files with 10 additions and 0 deletions

View File

@ -11,6 +11,16 @@ enum Instruction {
F, F,
} }
fn parse_orientation(c: char) -> Option<Orientation> {
match c {
'N' => Some(Orientation::N),
'E' => Some(Orientation::E),
'S' => Some(Orientation::S),
'W' => Some(Orientation::W),
_ => None,
}
}
fn main() { fn main() {
let file_data = include_str!("../two_robots.txt"); let file_data = include_str!("../two_robots.txt");
} }