diff --git a/crates/bevy_ecs/src/system/commands/entity_command.rs b/crates/bevy_ecs/src/system/commands/entity_command.rs index 4480d5b458fcb..4863af03a889c 100644 --- a/crates/bevy_ecs/src/system/commands/entity_command.rs +++ b/crates/bevy_ecs/src/system/commands/entity_command.rs @@ -24,6 +24,8 @@ use crate::{ }; use bevy_ptr::{move_as_ptr, OwningPtr}; +use bevy_platform::sync::Arc; + /// A command which gets executed for a given [`Entity`]. /// /// Should be used with [`EntityCommands::queue`](crate::system::EntityCommands::queue). @@ -127,6 +129,18 @@ where } } +impl EntityCommand for Arc +where + F: Fn(EntityWorldMut) -> Out + Send + Sync + ?Sized + 'static, + Out: EntityCommandOutput + 'static, +{ + type Out = Out; + + fn apply(self, entity: EntityWorldMut) -> Self::Out { + self(entity) + } +} + /// An [`EntityCommand`] that adds the components in a [`Bundle`] to an entity. #[track_caller] pub fn insert(bundle: impl Bundle, mode: InsertMode) -> impl EntityCommand {