Create an example showcasing disjoint mutable access to the world via `unsafe_world_cell`
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
I recently discovered that bevy allows you to have disjoint mutable access to the world by using `unsafe_world_cell` (the user has to make sure that they don't access to conflicting queries at once).
This seems like a very powerful pattern which would be nice to showcase in an example.
For instance, you could want to display some `egui` ui, and have access to `&mut World` inside your ui to perform other operations; something like:
```
pub(crate) fn lobby_ui(world: &mut World, mut contexts: &mut SystemState>) {
let cell = world.as_unsafe_world_cell();
let (mut contexts, mut lobby_table) = contexts.get_mut(cell.world_mut());
let world = cell.world_mut();
egui::Window::new("Lobby").show(contexts.ctx_mut(), |ui| {
lobby_table.table_ui(ui, world);
});
}
```
The `SystemState` docs show a pattern where you can use them in combination with `&mut World` in an exclusive system, but they only show usages where you first use your system_state, and then you use `&mut World`, but never both in parallel. This example would showcase accessing both in parallel.
Contributor guide
Assessment
This issue has not been assessed yet.