Skip to content

Commit

Permalink
IntoIterator for EventReader (bevyengine#7720)
Browse files Browse the repository at this point in the history
# Objective
Continuation of bevyengine#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 authored and myreprise1 committed Feb 18, 2023
1 parent b2c5d64 commit c0ed1b5
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 c0ed1b5

Please sign in to comment.