@@ -50,6 +50,21 @@ pub struct SystemMeta {
5050 pub ( crate ) commands_span : Span ,
5151}
5252
53+ /// Trait for retrieving system metas.
54+ pub trait SystemMetaProvider {
55+ /// Returns immutable references of system metas as a vector.
56+ fn system_metas ( & self ) -> Vec < & SystemMeta > ;
57+
58+ /// Returns mutable references of system metas as a vector.
59+ fn system_metas_mut ( & mut self ) -> Vec < & mut SystemMeta > ;
60+
61+ /// Helper method for `system_metas`.
62+ fn extend_with_system_metas < ' a > ( & ' a self , vec : & mut Vec < & ' a SystemMeta > ) ;
63+
64+ /// Helper method for `system_metas_mut`.
65+ fn extend_with_system_metas_mut < ' a > ( & ' a mut self , vec_mut : & mut Vec < & ' a mut SystemMeta > ) ;
66+ }
67+
5368impl SystemMeta {
5469 pub ( crate ) fn new < T > ( ) -> Self {
5570 let name = core:: any:: type_name :: < T > ( ) ;
@@ -826,6 +841,32 @@ where
826841{
827842}
828843
844+ impl < Marker , F > SystemMetaProvider for FunctionSystem < Marker , F >
845+ where
846+ Marker : ' static ,
847+ F : SystemParamFunction < Marker > ,
848+ {
849+ fn system_metas ( & self ) -> Vec < & SystemMeta > {
850+ let mut vec: Vec < & SystemMeta > = Vec :: new ( ) ;
851+ self . extend_with_system_metas ( & mut vec) ;
852+ vec
853+ }
854+
855+ fn system_metas_mut ( & mut self ) -> Vec < & mut SystemMeta > {
856+ let mut vec: Vec < & mut SystemMeta > = Vec :: new ( ) ;
857+ self . extend_with_system_metas_mut ( & mut vec) ;
858+ vec
859+ }
860+
861+ fn extend_with_system_metas < ' a > ( & ' a self , vec : & mut Vec < & ' a SystemMeta > ) {
862+ vec. push ( & self . system_meta ) ;
863+ }
864+
865+ fn extend_with_system_metas_mut < ' a > ( & ' a mut self , vec_mut : & mut Vec < & ' a mut SystemMeta > ) {
866+ vec_mut. push ( & mut self . system_meta ) ;
867+ }
868+ }
869+
829870/// A trait implemented for all functions that can be used as [`System`]s.
830871///
831872/// This trait can be useful for making your own systems which accept other systems,
0 commit comments