bevy/crates
JoJoJet 2cff2278ca Add a method for mapping Mut<T> -> Mut<U> (#6199)
# Objective

When designing an API, you may wish to provide access only to a specific field of a component or resource. The current options for doing this in safe code are

* `*Mut::into_inner`, which flags a change no matter what.
* `*Mut::bypass_change_detection`, which misses all changes.

## Solution

Add the method `map_unchanged`.

### Example

```rust
// When run, zeroes the translation of every entity.
fn reset_all(mut transforms: Query<&mut Transform>) {
    for transform in &mut transforms {
        // We pinky promise not to modify `t` within the closure.
        let translation = transform.map_unchanged(|t| &mut t.translation);
        // Only reset the translation if it isn't already zero.
        translation.set_if_not_equal(Vec2::ZERO);
    }
}
```

---

## Changelog

+ Added the method `map_unchanged` to types `Mut<T>`, `ResMut<T>`, and `NonSendMut<T>`.
2022-10-10 17:06:31 +00:00
..
bevy_animation Exclusive Systems Now Implement System. Flexible Exclusive System Params (#6083) 2022-09-26 23:57:07 +00:00
bevy_app Exclusive Systems Now Implement System. Flexible Exclusive System Params (#6083) 2022-09-26 23:57:07 +00:00
bevy_asset Reflect Default for ComputedVisibility and Handle<T> (#6187) 2022-10-06 19:31:47 +00:00
bevy_audio Update rodio requirement from 0.15 to 0.16 (#6020) 2022-09-19 13:56:56 +00:00
bevy_core Fixes Camera not being serializable due to missing registrations in core functionality. (#6170) 2022-10-10 16:34:22 +00:00
bevy_core_pipeline Accept Bundles for insert and remove. Deprecate insert/remove_bundle (#6039) 2022-09-21 21:47:53 +00:00
bevy_derive Bump Version after Release (#5576) 2022-08-05 02:03:05 +00:00
bevy_diagnostic add globals to mesh view bind group (#5409) 2022-09-28 04:20:27 +00:00
bevy_dylib Bump Version after Release (#5576) 2022-08-05 02:03:05 +00:00
bevy_dynamic_plugin Bump Version after Release (#5576) 2022-08-05 02:03:05 +00:00
bevy_ecs Add a method for mapping Mut<T> -> Mut<U> (#6199) 2022-10-10 17:06:31 +00:00
bevy_ecs_compile_fail_tests Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
bevy_encase_derive Bump Version after Release (#5576) 2022-08-05 02:03:05 +00:00
bevy_gilrs Exclusive Systems Now Implement System. Flexible Exclusive System Params (#6083) 2022-09-26 23:57:07 +00:00
bevy_gltf Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
bevy_hierarchy Fix inconsistent children removal behavior (#6017) 2022-10-06 21:39:34 +00:00
bevy_input Exclusive Systems Now Implement System. Flexible Exclusive System Params (#6083) 2022-09-26 23:57:07 +00:00
bevy_internal fix #6062 incorrect links for render module docs (#6099) 2022-09-28 21:02:26 +00:00
bevy_log Make Resource trait opt-in, requiring #[derive(Resource)] V2 (#5577) 2022-08-08 21:36:35 +00:00
bevy_macro_utils Bump Version after Release (#5576) 2022-08-05 02:03:05 +00:00
bevy_math Add Camera::viewport_to_world (#6126) 2022-10-05 22:16:26 +00:00
bevy_mikktspace Bump Version after Release (#5576) 2022-08-05 02:03:05 +00:00
bevy_pbr get proper texture format after the renderer is initialized, fix #3897 (#5413) 2022-10-10 16:10:05 +00:00
bevy_ptr Bump Version after Release (#5576) 2022-08-05 02:03:05 +00:00
bevy_reflect Impl Reflect for PathBuf and OsString (#6193) 2022-10-08 17:02:21 +00:00
bevy_render Fixes Camera not being serializable due to missing registrations in core functionality. (#6170) 2022-10-10 16:34:22 +00:00
bevy_scene Exclusive Systems Now Implement System. Flexible Exclusive System Params (#6083) 2022-09-26 23:57:07 +00:00
bevy_sprite Rename Transform::mul_vec3 to transform_point and improve docs (#6132) 2022-10-10 16:50:17 +00:00
bevy_tasks Nested spawns on scope (#4466) 2022-09-28 01:59:10 +00:00
bevy_text make Handle::<T> field id private, and replace with a getter (#6176) 2022-10-06 13:33:30 +00:00
bevy_time Fix doc for Timer::percent_left (#6198) 2022-10-08 14:51:21 +00:00
bevy_transform Remove Transform::apply_non_uniform_scale (#6133) 2022-10-10 16:50:18 +00:00
bevy_ui get proper texture format after the renderer is initialized, fix #3897 (#5413) 2022-10-10 16:10:05 +00:00
bevy_utils Remove Sync bound from Local (#5483) 2022-09-12 04:15:55 +00:00
bevy_window Make bevy_window and bevy_input events serializable (#6180) 2022-10-06 13:14:23 +00:00
bevy_winit disable window pre creation for ios (#5883) 2022-09-06 15:06:17 +00:00