From bb58983b6c5f1633aa2ae27e4ad7938dfa6c8bff Mon Sep 17 00:00:00 2001 From: Martin HART Date: Tue, 20 Oct 2020 21:39:45 +0200 Subject: [PATCH] Change .create_map() to .create(), and turn* to set* --- src/main.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index fb7b826..465bd1a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ struct World { impl World { /// Create a new map full of dots. - fn create_map(&mut self) { + fn create(&mut self) { self.map = vec!['.'; (self.x * self.y) as usize]; } /// Set robot on the map. @@ -74,19 +74,19 @@ impl Robot { } } /// Apply North orientation to the robot. - fn turn_north(&mut self) { + fn set_north(&mut self) { self.o = Orientation::N } /// Apply South orientation to the robot. - fn turn_south(&mut self) { + fn set_south(&mut self) { self.o = Orientation::S } /// Apply East orientation to the robot. - fn turn_east(&mut self) { + fn set_east(&mut self) { self.o = Orientation::E } /// Apply West orientation to the robot. - fn turn_west(&mut self) { + fn set_west(&mut self) { self.o = Orientation::W } } @@ -183,13 +183,13 @@ mod tests { } #[test] - fn test_create_map() { + fn test_create() { let mut w: World = World { x: 5, y: 5, map: Vec::new(), }; - w.create_map(); + w.create(); assert_eq!(w.map, vec!['.'; 25]); } @@ -206,7 +206,7 @@ mod tests { y: 2, map: Vec::new(), }; - w.create_map(); + w.create(); w.set_robot(r); assert_eq!(w.map, vec!['↑', '.', '.', '.']); } @@ -218,7 +218,7 @@ mod tests { y: 2, map: Vec::new(), }; - w.create_map(); + w.create(); assert!(w.empty_position(Position { x: 0, y: 0 })); } }