Read-only queries cannot be issued on a read-only &World
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Problem
Given a `&World`, I cannot issue a query that only reads from the world.
There are two possible methods on `World` for this: `query`, `query_filtered`, plus `SystemState::new()`. All of them require `&mut World`, as they *could* provide mutating type parameters.
## Proposed Solutions
### Quick-and-dirty
Make read-only variants of all three methods.
### Ergonomic
Add a `system_state` and `read_only_system_state` method to `World`, which generates a `SystemState` and then immediately calls `.get_mut` / `.get` on it.
This allows users to do things like:
```rust
let query = world.read_only_system_state::>>();
for (foo, bar) in query.iter(){
}
```
Contributor guide
Assessment
This issue has not been assessed yet.