Skip to content

Commit

Permalink
add any() check to event reader that consumes the iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
IceSentry committed May 7, 2022
1 parent d867b61 commit e4f27b6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/bevy_ecs/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,15 @@ impl<'w, 's, T: Resource> EventReader<'w, 's, T> {
self.events.event_reader_len(self.last_event_count.0)
}

/// Determines if are any events available to be read without consuming any.
/// Determines if there are any events available to be read without consuming any.
pub fn is_empty(&self) -> bool {
self.len() == 0
}

/// Determines if there are any events available to be read and consumes all events.
pub fn any(&mut self) -> bool {
self.iter().last().is_some()
}
}

impl<T: Resource> Events<T> {
Expand Down

0 comments on commit e4f27b6

Please sign in to comment.