Skip to content

Commit 195a583

Browse files
mockersfrobtfm
authored andcommitted
exact sized event iterators (bevyengine#3863)
# Objective - Remove `Resource` binding on events, introduce a new `Event` trait - Ensure event iterators are `ExactSizeIterator` ## Solution - Builds on bevyengine#2382 and bevyengine#2969 ## Changelog - Events<T>, EventWriter<T>, EventReader<T> and so on now require that the underlying type is Event, rather than Resource. Both of these are trivial supertraits of Send + Sync + 'static with universal blanket implementations: this change is currently purely cosmetic. - Event reader iterators now implement ExactSizeIterator
1 parent 2aabbea commit 195a583

File tree

2 files changed

+147
-83
lines changed

2 files changed

+147
-83
lines changed

crates/bevy_app/src/app.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{CoreStage, Plugin, PluginGroup, PluginGroupBuilder, StartupSchedule, StartupStage};
22
pub use bevy_derive::AppLabel;
33
use bevy_ecs::{
4-
event::Events,
4+
event::{Event, Events},
55
prelude::{FromWorld, IntoExclusiveSystem},
66
schedule::{
77
IntoSystemDescriptor, Schedule, ShouldRun, Stage, StageLabel, State, StateData, SystemSet,
@@ -622,7 +622,7 @@ impl App {
622622
/// ```
623623
pub fn add_event<T>(&mut self) -> &mut Self
624624
where
625-
T: Resource,
625+
T: Event,
626626
{
627627
if !self.world.contains_resource::<Events<T>>() {
628628
self.init_resource::<Events<T>>()

0 commit comments

Comments
 (0)