mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
ddbfa48711
# Objective The `QueryParIter::for_each_mut` function is required when doing parallel iteration with mutable queries. This results in an unfortunate stutter: `query.par_iter_mut().par_for_each_mut()` ('mut' is repeated). ## Solution - Make `for_each` compatible with mutable queries, and deprecate `for_each_mut`. In order to prevent `for_each` from being called multiple times in parallel, we take ownership of the QueryParIter. --- ## Changelog - `QueryParIter::for_each` is now compatible with mutable queries. `for_each_mut` has been deprecated as it is now redundant. ## Migration Guide The method `QueryParIter::for_each_mut` has been deprecated and is no longer functional. Use `for_each` instead, which now supports mutable queries. ```rust // Before: query.par_iter_mut().for_each_mut(|x| ...); // After: query.par_iter_mut().for_each(|x| ...); ``` The method `QueryParIter::for_each` now takes ownership of the `QueryParIter`, rather than taking a shared reference. ```rust // Before: let par_iter = my_query.par_iter().batching_strategy(my_batching_strategy); par_iter.for_each(|x| { // ...Do stuff with x... par_iter.for_each(|y| { // ...Do nested stuff with y... }); }); // After: my_query.par_iter().batching_strategy(my_batching_strategy).for_each(|x| { // ...Do stuff with x... my_query.par_iter().batching_strategy(my_batching_strategy).for_each(|y| { // ...Do nested stuff with y... }); }); ``` |
||
---|---|---|
.. | ||
benches | ||
Cargo.toml |