Used the zip function to iterate over both vectors simultaneously instead of an

index variable and unwrapping the result.
This commit is contained in:
MaximilianDauner 2018-03-23 20:13:13 +01:00
parent 18ef5874dd
commit b42e54f13f

View file

@ -37,10 +37,8 @@ impl GamepadButtonList {
}
pub fn sync_from_vr(&self, vr_buttons: &[WebVRGamepadButton]) {
let mut index = 0;
for btn in vr_buttons {
self.list.get(index).as_ref().unwrap().update(btn.pressed, btn.touched);
index += 1;
for (gp_btn, btn) in self.list.iter().zip(vr_buttons.iter()) {
gp_btn.update(btn.pressed, btn.touched);
}
}
}