From 71d9c799b6c289a8299a089aafdd16d048851553 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Tue, 31 Oct 2023 22:51:32 +0000 Subject: [PATCH] rover moves forward northward when pointing north --- src/main.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index c1a4509..c4ea4b8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,15 +1,27 @@ fn main() { println!("Hello, world!"); } + +mod rover { + #[derive(Debug,PartialEq)] + pub enum Facing { N, E, S, W } + + type Rover = (i32, i32, Facing); + + pub fn forward(r : Rover) -> Rover { + (1 as i32, 0 as i32, Facing::N) + } +} + #[cfg(test)] mod tests { + use super::*; + #[test] fn rover_run() { assert_eq!(1,1); - } - - #[test] - fn failure_run() { - assert_eq!(1,0); + let r = (1 as i32, 1 as i32, rover::Facing::N); + assert_eq!(rover::forward(r), + (1 as i32, 0 as i32, rover::Facing::N)); } }