servo: Merge #20404 - GamepadButtonList::sync_from_vr should use more iterators #20392 (from MaximilianDauner:issue_20392); r=jdm

<!-- Please describe your changes on the following line: -->
Used the zip function instead of iterating over both vectors with an indexing variable and using unwrap.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #20392(github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because it says in the issue description no need for tests
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 5a432eaad33f36591f62c3d2671ffd9956be3594

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 4aa46a5256c0be438435e5f72af0f2b3468fd97e
This commit is contained in:
MaximilianDauner 2018-03-23 23:15:51 -04:00
Родитель d43e36ae5b
Коммит 76d07ca4c5
1 изменённых файлов: 2 добавлений и 4 удалений

Просмотреть файл

@ -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);
}
}
}