@@ -721,11 +721,83 @@ pub fn derive_from_world(input: TokenStream) -> TokenStream {
721721 } )
722722}
723723
724+ /// Automatically compose systems together with function syntax.
725+ ///
726+ /// This macro provides some nice syntax on top of the `SystemRunner` `SystemParam`
727+ /// to allow running systems inside other systems. Overall, the macro accepts normal
728+ /// closure syntax:
729+ ///
730+ /// ```ignore
731+ /// let system_a = |world: &mut World| { 10 };
732+ /// let system_b = |a: In<u32>, world: &mut World| { println!("{}", *a + 12) };
733+ /// compose! {
734+ /// || -> Result<(), RunSystemError> {
735+ /// let a = run!(system-a)?;
736+ /// run!(system_b);
737+ /// }
738+ /// }
739+ /// ```
740+ ///
741+ /// What's special is that the macro will expand any invocations of `run!()` into
742+ /// calls to `SystemRunner::run` or `SystemRunner::run_with`. The `run!()` accepts
743+ /// two parameters: first, a system identifier (or a path to one), and second, an
744+ /// optional input to invoke the system with.
745+ ///
746+ /// Notes:
747+ /// 1. All system runners are passed through a `ParamSet`, so invoked systems will
748+ /// not conflict with each other. However, invoked systems may still conflict
749+ /// with system params in the outer closure.
750+ ///
751+ /// 2. `run!` will not accept expressions that evaluate to systems, only direct
752+ /// identifiers or paths. So, if you want to call something like:
753+ ///
754+ /// ```ignore
755+ /// run!(|query: Query<(&A, &B, &mut C)>| { ... })`
756+ /// ```
757+ ///
758+ /// Assign the expression to a variable first.
724759#[ proc_macro]
725760pub fn compose ( input : TokenStream ) -> TokenStream {
726761 system_composition:: compose ( input, false )
727762}
728763
764+ /// Automatically compose systems together with function syntax.
765+ ///
766+ /// Unlike [`compose`], this macro allows generating systems that take input.
767+ ///
768+ /// This macro provides some nice syntax on top of the `SystemRunner` `SystemParam`
769+ /// to allow running systems inside other systems. Overall, the macro accepts normal
770+ /// closure syntax:
771+ ///
772+ /// ```ignore
773+ /// let system_a = |input: In<u32>, world: &mut World| { *input + 10 };
774+ /// let system_b = |a: In<u32>, world: &mut World| { println!("{}", *a + 12) };
775+ /// compose_with! {
776+ /// |input: In<u32>| -> Result<(), RunSystemError> {
777+ /// let a = run!(system_a, input)?;
778+ /// run!(system_b);
779+ /// }
780+ /// }
781+ /// ```
782+ ///
783+ /// What's special is that the macro will expand any invocations of `run!()` into
784+ /// calls to `SystemRunner::run` or `SystemRunner::run_with`. The `run!()` accepts
785+ /// two parameters: first, a system identifier (or a path to one), and second, an
786+ /// optional input to invoke the system with.
787+ ///
788+ /// Notes:
789+ /// 1. All system runners are passed through a `ParamSet`, so invoked systems will
790+ /// not conflict with each other. However, invoked systems may still conflict
791+ /// with system params in the outer closure.
792+ ///
793+ /// 2. `run!` will not accept expressions that evaluate to systems, only direct
794+ /// identifiers or paths. So, if you want to call something like:
795+ ///
796+ /// ```ignore
797+ /// run!(|query: Query<(&A, &B, &mut C)>| { ... })`
798+ /// ```
799+ ///
800+ /// Assign the expression to a variable first.
729801#[ proc_macro]
730802pub fn compose_with ( input : TokenStream ) -> TokenStream {
731803 system_composition:: compose ( input, true )
0 commit comments