diff --git a/crates/bevy_ecs/src/system/system_chaining.rs b/crates/bevy_ecs/src/system/system_chaining.rs index 95f597409870b..736bf066331ea 100644 --- a/crates/bevy_ecs/src/system/system_chaining.rs +++ b/crates/bevy_ecs/src/system/system_chaining.rs @@ -2,7 +2,7 @@ use crate::{ archetype::{Archetype, ArchetypeComponentId}, component::ComponentId, query::Access, - system::{System, SystemId}, + system::{IntoSystem, System, SystemId}, world::World, }; use std::borrow::Cow; @@ -29,7 +29,7 @@ use std::borrow::Cow; /// world.insert_resource(Message("42".to_string())); /// /// // chain the `parse_message_system`'s output into the `filter_system`s input -/// let mut chained_system = parse_message_system.system().chain(filter_system.system()); +/// let mut chained_system = parse_message_system.chain(filter_system); /// chained_system.initialize(&mut world); /// assert_eq!(chained_system.run((), &mut world), Some(42)); /// } @@ -118,25 +118,29 @@ impl> System for ChainSystem /// This trait is blanket implemented for all system pairs that fulfill the chaining requirement. /// /// See [`ChainSystem`]. -pub trait IntoChainSystem: System + Sized +pub trait IntoChainSystem: + IntoSystem<(), Payload, ParamA> + Sized where - SystemB: System, + SystemB: IntoSystem, { /// Chain this system `A` with another system `B` creating a new system that feeds system A's /// output into system `B`, returning the output of system `B`. - fn chain(self, system: SystemB) -> ChainSystem; + fn chain(self, system: SystemB) -> ChainSystem; } -impl IntoChainSystem for SystemA +impl + IntoChainSystem for SystemA where - SystemA: System, - SystemB: System, + SystemA: IntoSystem<(), Payload, ParamA>, + SystemB: IntoSystem, { - fn chain(self, system: SystemB) -> ChainSystem { + fn chain(self, system: SystemB) -> ChainSystem { + let system_a = self.system(); + let system_b = system.system(); ChainSystem { - name: Cow::Owned(format!("Chain({}, {})", self.name(), system.name())), - system_a: self, - system_b: system, + name: Cow::Owned(format!("Chain({}, {})", system_a.name(), system_b.name())), + system_a, + system_b, archetype_component_access: Default::default(), component_access: Default::default(), id: SystemId::new(),