Skip to content

Commit b968fc4

Browse files
committed
IntoIterator for RemovedComponents
1 parent b4392be commit b968fc4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

crates/bevy_ecs/src/removal_detection.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,15 @@ impl<'w, 's, T: Component> RemovedComponents<'w, 's, T> {
122122
}
123123
}
124124
}
125+
126+
impl<'a, 'w, 's: 'a, T> IntoIterator for &'a mut RemovedComponents<'w, 's, T>
127+
where
128+
T: Component,
129+
{
130+
type Item = Entity;
131+
type IntoIter = Box<dyn Iterator<Item = Entity> + 'a>;
132+
fn into_iter(self) -> Self::IntoIter {
133+
self.iter()
134+
}
135+
}
136+

examples/ecs/removal_detection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn remove_component(
5454
fn react_on_removal(mut removed: RemovedComponents<MyComponent>, mut query: Query<&mut Sprite>) {
5555
// `RemovedComponents<T>::iter()` returns an interator with the `Entity`s that had their
5656
// `Component` `T` (in this case `MyComponent`) removed at some point earlier during the frame.
57-
for entity in removed.iter() {
57+
for entity in &mut removed {
5858
if let Ok(mut sprite) = query.get_mut(entity) {
5959
sprite.color.set_r(0.0);
6060
}

0 commit comments

Comments
 (0)