bevy/crates/bevy_ecs/src/query
JoJoJet 3fba34c9e6
Require read-only queries in QueryState::par_iter (#8832)
# Objective

The method `QueryState::par_iter` does not currently force the query to
be read-only. This means you can unsoundly mutate a world through an
immutable reference in safe code.

```rust
fn bad_system(world: &World, mut query: Local<QueryState<&mut T>>) {
    query.par_iter(world).for_each_mut(|mut x| *x = unsoundness);
}
```

## Solution

Use read-only versions of the `WorldQuery` types.

---

## Migration Guide

The function `QueryState::par_iter` now forces any world accesses to be
read-only, similar to how `QueryState::iter` works. Any code that
previously mutated the world using this method was *unsound*. If you
need to mutate the world, use `par_iter_mut` instead.
2023-06-13 01:17:40 +00:00
..
access.rs Document every public item in bevy_ecs (#8731) 2023-06-10 23:23:48 +00:00
fetch.rs Document every public item in bevy_ecs (#8731) 2023-06-10 23:23:48 +00:00
filter.rs Fix 1.69 CI clippy lints (#8450) 2023-04-20 16:51:21 +00:00
iter.rs Increase type safety and clarity for change detection (#7905) 2023-03-09 17:17:02 +00:00
mod.rs Document every public item in bevy_ecs (#8731) 2023-06-10 23:23:48 +00:00
par_iter.rs Document every public item in bevy_ecs (#8731) 2023-06-10 23:23:48 +00:00
state.rs Require read-only queries in QueryState::par_iter (#8832) 2023-06-13 01:17:40 +00:00