Unpack some deep nesting as per code review
@@ -23,7 +23,11 @@ pub fn broadcast_movement(game: &mut Game, world: &mut World) {
|(entity, (pos, prev_pos, id))| {
let pos: Position = *pos;
- if let Some(prev_pos) = prev_pos.0 {
+ let prev_pos = match prev_pos.0 {
+ Some(prev_pos) => prev_pos,
+ None => return,
+ };
+
if pos == prev_pos {
return;
}
@@ -57,7 +61,6 @@ pub fn broadcast_movement(game: &mut Game, world: &mut World) {
};
}
}
- }
},
);
}
@@ -98,7 +101,11 @@ pub fn broadcast_velocity(world: &mut World, game: &mut Game) {
|(entity, (vel, prev_vel, entity_id))| {
let entity_id = entity_id.0;
- if let Some(prev_vel) = prev_vel.0 {
+ let prev_vel = match prev_vel.0 {
+ Some(prev_vel) => prev_vel,
+ None => return,
+ };
+
if vel.0 == prev_vel {
return;
}
@@ -116,7 +123,6 @@ pub fn broadcast_velocity(world: &mut World, game: &mut Game) {
velocity_z,
};
game.broadcast_entity_update(world, packet, entity, None);
- }
},
);
}
