diff --git a/crates/bevy_ecs/src/event.rs b/crates/bevy_ecs/src/event.rs index 78f3e46a8a..b7ea293b21 100644 --- a/crates/bevy_ecs/src/event.rs +++ b/crates/bevy_ecs/src/event.rs @@ -226,7 +226,7 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> { /// # /// struct CollisionEvent; /// - /// fn play_collision_sound(events: EventReader) { + /// fn play_collision_sound(mut events: EventReader) { /// if !events.is_empty() { /// events.clear(); /// // Play a sound @@ -246,7 +246,7 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> { /// In those situations you generally want to consume those events to make sure they don't appear in the next frame. /// /// For more information see [`EventReader::is_empty()`]. - pub fn clear(mut self) { + pub fn clear(&mut self) { self.iter().last(); } } @@ -817,7 +817,7 @@ mod tests { events.send(TestEvent { i: 0 }); world.insert_resource(events); - let mut reader = IntoSystem::into_system(|events: EventReader| -> bool { + let mut reader = IntoSystem::into_system(|mut events: EventReader| -> bool { if !events.is_empty() { events.clear(); false diff --git a/examples/games/breakout.rs b/examples/games/breakout.rs index 042190e501..263a148b66 100644 --- a/examples/games/breakout.rs +++ b/examples/games/breakout.rs @@ -404,7 +404,7 @@ fn check_for_collisions( } fn play_collision_sound( - collision_events: EventReader, + mut collision_events: EventReader, audio: Res