IntoIterator for EventReader (#7720)

# Objective
Continuation of https://github.com/bevyengine/bevy/pull/5719
Now that we have a definable type for the iterator.

---

## Changelog
- Implemented IntoIterator for EventReader so you can now do `&mut reader` instead of `reader.iter()` for events.
This commit is contained in:
Aceeri 2023-02-17 15:37:36 +00:00
parent 18cfb226db
commit b24ed8bb0c

View File

@ -241,6 +241,14 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> {
}
}
impl<'a, 'w, 's, E: Event> IntoIterator for &'a mut EventReader<'w, 's, E> {
type Item = &'a E;
type IntoIter = ManualEventIterator<'a, E>;
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}
/// Sends events of type `T`.
///
/// # Usage