From f4dde09370f2d19577afd6acc38beb183069e4f3 Mon Sep 17 00:00:00 2001 From: Volodymyr Patuta <6977238-fiplox@users.noreply.gitlab.com> Date: Fri, 30 Oct 2020 15:59:01 +0100 Subject: [PATCH] fixed check_map() --- src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 13b6b44..690742a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,7 @@ mod world; /// Check if the robot is in the map. fn check_map(r: &robot::Robot, w: &world::World) -> Result<(), String> { - if (r.p.x, r.p.y) < (0, 0) || (r.p.x, r.p.y) > (w.x, w.y) { + if r.p.x < 0 || r.p.y < 0 || r.p.x > w.x || r.p.y > w.y { Err(format!("The robot {} is off map", r.id)) } else { Ok(()) @@ -129,10 +129,10 @@ mod tests { let mut r = robot::Robot::new( 0, robot::Orientation::N, - robot::Position { x: 2, y: 3 }, + robot::Position { x: 2, y: 4 }, vec!['F'], ); - let w = world::World { x: 1, y: 1 }; + let w = world::World { x: 3, y: 3 }; assert!(check_map(&r, &w).is_ok()); }