bevy/crates
Joseph 218f78157d
Require &mut self for World::increment_change_tick (#14459)
# Objective

The method `World::increment_change_tick` currently takes `&self` as the
method receiver, which is semantically strange. Even though the interior
mutability is sound, the existence of this method is strange since we
tend to think of `&World` as being a read-only snapshot of a world, not
an aliasable reference to a world with mutability. For those purposes,
we have `UnsafeWorldCell`.

## Solution

Change the method signature to take `&mut self`. Use exclusive access to
remove the need for atomic adds, which makes the method slightly more
efficient. Redirect users to [`UnsafeWorldCell::increment_change_tick`]
if they need to increment the world's change tick from an aliased
context.

In practice I don't think there will be many breakages, if any. In cases
where you need to call `increment_change_tick`, you usually already have
either `&mut World` or `UnsafeWorldCell`.

---

## Migration Guide

The method `World::increment_change_tick` now requires `&mut self`
instead of `&self`. If you need to call this method but do not have
mutable access to the world, consider using
`world.as_unsafe_world_cell_readonly().increment_change_tick()`, which
does the same thing, but is less efficient than the method on `World`
due to requiring atomic synchronization.

```rust
fn my_system(world: &World) {
    // Before
    world.increment_change_tick();

    // After
    world.as_unsafe_world_cell_readonly().increment_change_tick();
}
```
2024-07-24 12:42:28 +00:00
..
bevy_a11y Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_animation Fix repeated animation transition bug (#14411) 2024-07-22 19:17:46 +00:00
bevy_app Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_asset Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_audio Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_color Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_core Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_core_pipeline Fixup Msaa docs. (#14442) 2024-07-22 21:37:25 +00:00
bevy_derive Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_dev_tools Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_diagnostic Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_dylib Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_dynamic_plugin Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_ecs Require &mut self for World::increment_change_tick (#14459) 2024-07-24 12:42:28 +00:00
bevy_encase_derive Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_gilrs Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_gizmos Don't ignore draw errors (#13240) 2024-07-22 19:22:30 +00:00
bevy_gltf Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_hierarchy Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_input feature: Derive Hash for KeyboardInput. (#14263) 2024-07-23 12:29:15 +00:00
bevy_internal Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_log Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_macro_utils Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_math Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_mikktspace Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_pbr Fixup Msaa docs. (#14442) 2024-07-22 21:37:25 +00:00
bevy_picking Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_ptr Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_reflect Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_render Don't ignore draw errors (#13240) 2024-07-22 19:22:30 +00:00
bevy_scene Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_sprite Don't ignore draw errors (#13240) 2024-07-22 19:22:30 +00:00
bevy_state Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_tasks Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_text feat: expose the default font bytes (#14406) 2024-07-22 19:09:39 +00:00
bevy_time Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_transform Only propagate transforms entities with GlobalTransforms. (#14384) 2024-07-22 19:07:21 +00:00
bevy_ui Add and reflect Default impls for CSS grid types (#14443) 2024-07-22 21:39:59 +00:00
bevy_utils Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_window Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00
bevy_winit Remove manual --cfg docsrs (#14376) 2024-07-22 18:58:04 +00:00