Repository: bevyengine/bevy
File: crates/bevy_ecs/src/query/state.rs (Rust)

Code before:
        QueryCombinationIter::new(world, self, last_run, this_run)
    }

    /// Runs `func` on each query result for the given [`World`]. This is faster than the equivalent
    /// iter() method, but cannot be chained like a normal [`Iterator`].
    ///
    /// This can only be called for read-only queries, see [`Self::for_each_mut`] for write-queries.
    ///
    /// Shorthand for `query.iter(world).for_each(..)`.
    #[inline]
    #[deprecated(
        since = "0.13.0",
        note = "QueryState::for_each was not idiomatic Rust and has been moved to query.iter().for_each()"
    )]
    pub fn for_each<'w, FN: FnMut(ROQueryItem<'w, Q>)>(&mut self, world: &'w World, func: FN) {
        self.iter(world).for_each(func);
    }

    /// Runs `func` on each query result for the given [`World`]. This is faster than the equivalent
    /// `iter_mut()` method, but cannot be chained like a normal [`Iterator`].
    ///
    /// Shorthand for `query.iter_mut(world).for_each(..)`.
    #[inline]
    #[deprecated(
        since = "0.13.0",
        note = "QueryState::for_each_mut was not idiomatic Rust and has been moved to query.iter().for_each_mut()"
    )]
    pub fn for_each_mut<'w, FN: FnMut(Q::Item<'w>)>(&mut self, world: &'w mut World, func: FN) {
        self.iter_mut(world).for_each(func);
    }

    /// Runs `func` on each query result for the given [`World`]. This is faster than the equivalent
    /// iter() method, but cannot be chained like a normal [`Iterator`].
    ///
    /// # Safety
    ///
    /// This does not check for mutable query correctness. To be safe, make sure mutable queries
    /// have unique access to the components they query.
    #[inline]
    pub unsafe fn for_each_unchecked<'w, FN: FnMut(Q::Item<'w>)>(
        &mut self,
        world: UnsafeWorldCell<'w>,
        func: FN,
    ) {
        self.update_archetypes_unsafe_world_cell(world);
        self.iter_unchecked_manual(world, world.last_change_tick(), world.change_tick())
            .for_each(func);
    }

    /// Returns a parallel iterator over the query results for the given [`World`].
    ///

Review comment (suggestion):
```suggestion
        note = "QueryState::for_each_mut was not idiomatic Rust and has been moved to query.iter_mut().for_each()"
```

Code after:
    /// This can only be called for read-only queries, see [`Self::for_each_mut`] for write-queries.
    ///
    /// Shorthand for `query.iter(world).for_each(..)`.
    #[inline]
    #[deprecated(
        since = "0.13.0",
        note = "QueryState::for_each was not idiomatic Rust and has been moved to query.iter().for_each()"
    )]
    pub fn for_each<'w, FN: FnMut(ROQueryItem<'w, Q>)>(&mut self, world: &'w World, func: FN) {
        self.iter(world).for_each(func);
    }

    /// Runs `func` on each query result for the given [`World`]. This is faster than the equivalent
    /// `iter_mut()` method, but cannot be chained like a normal [`Iterator`].
    ///
    /// Shorthand for `query.iter_mut(world).for_each(..)`.
    #[inline]
    #[deprecated(
        since = "0.13.0",
        note = "QueryState::for_each_mut was not idiomatic Rust and has been moved to query.iter_mut().for_each()"
    )]
    pub fn for_each_mut<'w, FN: FnMut(Q::Item<'w>)>(&mut self, world: &'w mut World, func: FN) {
        self.iter_mut(world).for_each(func);
    }

    /// Runs `func` on each query result for the given [`World`]. This is faster than the equivalent
    /// iter() method, but cannot be chained like a normal [`Iterator`].
    ///
    /// # Safety
    ///
    /// This does not check for mutable query correctness. To be safe, make sure mutable queries
    /// have unique access to the components they query.
    #[inline]
    pub unsafe fn for_each_unchecked<'w, FN: FnMut(Q::Item<'w>)>(
        &mut self,
        world: UnsafeWorldCell<'w>,
        func: FN,
    ) {
        self.update_archetypes_unsafe_world_cell(world);
        self.iter_unchecked_manual(world, world.last_change_tick(), world.change_tick())
            .for_each(func);
    }

    /// Returns a parallel iterator over the query results for the given [`World`].
    ///
    /// This can only be called for read-only queries, see [`par_iter_mut`] for write-queries.
    ///
    /// [`par_iter_mut`]: Self::par_iter_mut
    #[inline]
    pub fn par_iter<'w, 's>(
        &'s mut self,