unused variable in check_world + HashMap fix

This commit is contained in:
Volodymyr Patuta 2020-10-31 17:55:47 +01:00
parent 1744899f88
commit 6cfe921110
1 changed files with 4 additions and 9 deletions

View File

@ -31,11 +31,7 @@ fn check_map(r: &robot::Robot, w: &world::World) -> Result<(), String> {
}
/// Check if the robot collide with another one at the given position.
fn check_collisions(
r: &robot::Robot,
w: &world::World,
h: &HashMap<&robot::Position, &u32>,
) -> Result<(), String> {
fn check_collisions(r: &robot::Robot, h: &HashMap<robot::Position, u32>) -> Result<(), String> {
match h.get(&r.p) {
Some(&x) => Err(format!(
"The robot id: {} collided with robot id: {} in position: ({};{}) !",
@ -262,10 +258,9 @@ mod tests {
robot::Position { x: 2, y: 3 },
vec!['F'],
);
let w = world::World { x: 10, y: 10 };
let mut h: HashMap<&robot::Position, &u32> = HashMap::new();
h.insert(&robot::Position { x: 2, y: 3 }, &1);
assert!(check_collisions(&r, &w, &h).is_ok());
let mut h: HashMap<robot::Position, u32> = HashMap::new();
h.insert(robot::Position { x: 2, y: 3 }, 1);
assert!(check_collisions(&r, &h).is_ok());
}
}