bevy/crates
Alix Bott dd4479ed30
Fix PartialReflect::apply for maps, remove get_at/_mut from Map trait (#19802)
# Objective

- Fixes https://github.com/bevyengine/bevy/issues/14328
- `DynamicMap::drain` was broken (indices weren't cleared, causing a
panic when reading later)
- `PartialReflect::apply` was broken for maps and sets, because they
don't remove entries from the `self` map that aren't in the applied map.
- I discovered this bug when implementing MapEntities on a Component
containing a `HashMap<Entity, _>`. Because `apply` is used to reapply
the changes to the reflected map, the map ended up littered with a ton
of outdated entries.

## Solution

- Remove the separate `Vec` in `DynamicMap` and use the `HashTable`
directly, like it is in `DynamicSet`.
- Replace `MapIter` by `Box<dyn Iterator>` (like for `DynamicSet`), and
`Map::get_at` and `Map::get_at_mut` which are now unused.
- Now assume `DynamicMap` types are unordered and adjust documentation
accordingly.
- Fix documentation of `DynamicSet` (ordered -> unordered)
- Added `Map::retain` and `Set::retain`, and use them to remove excess
entries in `PartialReflect::apply` implementations.

## Testing

- Added `map::tests::apply` and `set::tests::apply` to validate
`<DynamicMap as PartialReflect>::apply` and `<DynamicSet as
PartialReflect>::apply`
2025-06-25 15:42:01 +00:00
..
bevy_a11y Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_animation Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_anti_aliasing Replace FULLSCREEN_SHADER_HANDLE with a FullscreenShader resource. (#19426) 2025-06-24 00:02:23 +00:00
bevy_app Rename num_entities to entity_count (#19781) 2025-06-23 05:08:02 +00:00
bevy_asset Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_audio Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
bevy_color Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_core_pipeline Allow images to be resized on the GPU without losing data (#19462) 2025-06-24 06:22:50 +00:00
bevy_core_widgets Core radio button and radio group (#19778) 2025-06-24 00:38:31 +00:00
bevy_derive Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_dev_tools CI tests can exit directly after taking a screenshot (#19806) 2025-06-24 22:44:30 +00:00
bevy_diagnostic Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
bevy_dylib Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_ecs Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_encase_derive Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_gilrs Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
bevy_gizmos Allow images to be resized on the GPU without losing data (#19462) 2025-06-24 06:22:50 +00:00
bevy_gltf Allow setting correct glTF coordinate conversions globally (#19685) 2025-06-24 00:23:34 +00:00
bevy_image Allow images to be resized on the GPU without losing data (#19462) 2025-06-24 06:22:50 +00:00
bevy_input Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_input_focus Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_internal Split overloaded basis-universal feature into compressed_image_saver (#19789) 2025-06-24 03:09:28 +00:00
bevy_log Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_macro_utils Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_math Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_mesh Implement serializable mesh (#19743) 2025-06-24 00:32:34 +00:00
bevy_mikktspace Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_pbr Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_picking Upstream raycasting UVs (#19791) 2025-06-24 18:10:59 +00:00
bevy_platform Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_ptr Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
bevy_reflect Fix PartialReflect::apply for maps, remove get_at/_mut from Map trait (#19802) 2025-06-25 15:42:01 +00:00
bevy_remote Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_render Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_scene Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_solari Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_sprite TilemapChunk cleanup (#19795) 2025-06-24 22:25:59 +00:00
bevy_state Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_tasks Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_text Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_time Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_transform Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_ui Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_utils Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_window Update doc about Windows CursorGrabMode support (#19192) 2025-06-24 00:00:30 +00:00
bevy_winit Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00