unused variable in check_world + HashMap fix
This commit is contained in:
parent
1744899f88
commit
6cfe921110
13
src/main.rs
13
src/main.rs
@ -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.
|
/// Check if the robot collide with another one at the given position.
|
||||||
fn check_collisions(
|
fn check_collisions(r: &robot::Robot, h: &HashMap<robot::Position, u32>) -> Result<(), String> {
|
||||||
r: &robot::Robot,
|
|
||||||
w: &world::World,
|
|
||||||
h: &HashMap<&robot::Position, &u32>,
|
|
||||||
) -> Result<(), String> {
|
|
||||||
match h.get(&r.p) {
|
match h.get(&r.p) {
|
||||||
Some(&x) => Err(format!(
|
Some(&x) => Err(format!(
|
||||||
"The robot id: {} collided with robot id: {} in position: ({};{}) !",
|
"The robot id: {} collided with robot id: {} in position: ({};{}) !",
|
||||||
@ -262,10 +258,9 @@ mod tests {
|
|||||||
robot::Position { x: 2, y: 3 },
|
robot::Position { x: 2, y: 3 },
|
||||||
vec!['F'],
|
vec!['F'],
|
||||||
);
|
);
|
||||||
let w = world::World { x: 10, y: 10 };
|
|
||||||
|
|
||||||
let mut h: HashMap<&robot::Position, &u32> = HashMap::new();
|
let mut h: HashMap<robot::Position, u32> = HashMap::new();
|
||||||
h.insert(&robot::Position { x: 2, y: 3 }, &1);
|
h.insert(robot::Position { x: 2, y: 3 }, 1);
|
||||||
assert!(check_collisions(&r, &w, &h).is_ok());
|
assert!(check_collisions(&r, &h).is_ok());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user