Merge branch 'fix-collision' into 'master'
unused variable in check_world + HashMap fix See merge request mhart/DancingDroids!41
This commit is contained in:
		
						commit
						d0106b4d08
					
				
							
								
								
									
										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.
 | 
			
		||||
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());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user