Skip to content

Commit

Permalink
IntoIterator for EventReader (#7720)
Browse files Browse the repository at this point in the history
# Objective
Continuation of #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.
  • Loading branch information
Aceeri committed Feb 17, 2023
1 parent 18cfb22 commit b24ed8b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/bevy_ecs/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b24ed8b

Please sign in to comment.