From 927441d048a6bfb3ef3142bda519d482a4829720 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sat, 3 Sep 2022 18:06:42 +0000 Subject: [PATCH] Add From for EntityRef (fixes #5459) (#5461) Add From for EntityRef (fixes #5459) --- 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 2b6314536c..e4b7e072d4 100644 --- a/crates/bevy_ecs/src/world/entity_ref.rs +++ b/crates/bevy_ecs/src/world/entity_ref.rs @@ -128,6 +128,12 @@ impl<'w> EntityRef<'w> { } } +impl<'w> From> for EntityRef<'w> { + fn from(entity_mut: EntityMut<'w>) -> EntityRef<'w> { + EntityRef::new(entity_mut.world, entity_mut.entity, entity_mut.location) + } +} + /// A mutable reference to a particular [`Entity`] and all of its components pub struct EntityMut<'w> { world: &'w mut World,