dancing_droids/src/main.rs

36 lines
737 B
Rust
Raw Normal View History

2020-10-11 18:25:42 +02:00
enum Orientation {
2020-10-06 23:25:17 +02:00
N,
E,
S,
W,
2020-10-06 20:34:48 +02:00
}
2020-10-06 23:25:17 +02:00
2020-10-11 18:25:42 +02:00
enum Instruction {
L,
R,
F,
}
fn parse_orientation(c: &char) -> Result<Orientation, &'static str> {
match c {
'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) -> Result<Instruction, &'static str> {
match c {
'L' => Ok(Instruction::L),
'R' => Ok(Instruction::R),
'F' => Ok(Instruction::F),
_ => Err("Invalid character, does not match any instructions"),
}
}
fn main() {
let file_data = include_str!("../two_robots.txt");
}