From 1c47698453f3de7d7a440941d723f2feb06aa2c7 Mon Sep 17 00:00:00 2001 From: Martin HART Date: Sun, 8 Nov 2020 22:10:11 +0100 Subject: [PATCH] documentation --- src/main.rs | 1 + src/robot.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/main.rs b/src/main.rs index 52eebf3..4489af9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,6 +59,7 @@ fn create_hash_map(pool: &Vec, hash: &mut HashMap) -> Result { let w = world::random_world(); let mut rng = rand::thread_rng(); diff --git a/src/robot.rs b/src/robot.rs index aa96587..aa8d9e7 100644 --- a/src/robot.rs +++ b/src/robot.rs @@ -59,6 +59,7 @@ pub enum Orientation { W, } +/// Return new Orientation with a left move apply to it. fn turn_left(o: &Orientation) -> Orientation { match o { Orientation::N => Orientation::W, @@ -67,6 +68,8 @@ fn turn_left(o: &Orientation) -> Orientation { Orientation::W => Orientation::S, } } + +/// Return new Orientation with a right move apply to it. fn turn_right(o: &Orientation) -> Orientation { match o { Orientation::N => Orientation::E, @@ -84,6 +87,7 @@ pub enum Instruction { F, } +/// Convert a string of instructions to a Vec of instructions. pub fn instructions_from_string(s: String) -> Result, String> { let mut v: Vec = Vec::new(); for c in s.chars() {