From 4227781e8c107cbee57dd1009b465d5d20101718 Mon Sep 17 00:00:00 2001 From: Giacomo Stevanato Date: Sun, 7 Apr 2024 15:24:10 +0200 Subject: [PATCH] Implement `From<&'w mut EntityMut>` for `EntityMut<'w>` (#12896) # Objective - Implement `From<&'w mut EntityMut>` for `EntityMut<'w>`; - Make it possible to pass `&mut EntityMut` where `impl Into` is required; - Helps with #12895. ## Solution - Implement `From<&'w mut EntityMut>` for `EntityMut<'w>` --- ## Changelog - `EntityMut<'w>` now implements `From<&'w mut EntityMut>` --- crates/bevy_ecs/src/world/entity_ref.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/bevy_ecs/src/world/entity_ref.rs b/crates/bevy_ecs/src/world/entity_ref.rs index 3c79e13e0b..1308198186 100644 --- a/crates/bevy_ecs/src/world/entity_ref.rs +++ b/crates/bevy_ecs/src/world/entity_ref.rs @@ -469,6 +469,12 @@ impl<'w> EntityMut<'w> { } } +impl<'w> From<&'w mut EntityMut<'_>> for EntityMut<'w> { + fn from(value: &'w mut EntityMut<'_>) -> Self { + value.reborrow() + } +} + impl<'w> From> for EntityMut<'w> { fn from(value: EntityWorldMut<'w>) -> Self { // SAFETY: `EntityWorldMut` guarantees exclusive access to the entire world.