@@ -299,6 +299,52 @@ where
299299 }
300300}
301301
302+ /// Allows end users to call system-running methods from the [`System`](crate::system::System) trait without .system().
303+ pub trait RunnableSystem < In , Out , Param : SystemParam , Marker > :
304+ IntoSystem < In , Out , ( IsFunctionSystem , Param , Marker ) >
305+ {
306+ fn apply_buffers ( self , world : & mut World ) ;
307+
308+ fn initialize ( self , _world : & mut World ) ;
309+
310+ fn run ( self , input : In , world : & mut World ) -> Out ;
311+
312+ fn run_direct ( self , input : In , world : & mut World ) -> Out ;
313+ }
314+
315+ impl < In , Out , Param : SystemParam , Marker , F > RunnableSystem < In , Out , Param , Marker > for F
316+ where
317+ In : ' static ,
318+ Out : ' static ,
319+ Param : SystemParam + ' static ,
320+ Marker : ' static ,
321+ F : SystemParamFunction < In , Out , Param , Marker >
322+ + IntoSystem <
323+ In ,
324+ Out ,
325+ ( IsFunctionSystem , Param , Marker ) ,
326+ System = FunctionSystem < In , Out , Param , Marker , F > ,
327+ > + Send
328+ + Sync
329+ + ' static ,
330+ {
331+ fn apply_buffers ( self , world : & mut World ) {
332+ self . system ( ) . apply_buffers ( world) ;
333+ }
334+
335+ fn initialize ( self , world : & mut World ) {
336+ self . system ( ) . initialize ( world) ;
337+ }
338+
339+ fn run ( self , input : In , world : & mut World ) -> Out {
340+ self . system ( ) . run ( input, world)
341+ }
342+
343+ fn run_direct ( self , input : In , world : & mut World ) -> Out {
344+ self . system ( ) . run_direct ( input, world)
345+ }
346+ }
347+
302348pub struct IsFunctionSystem ;
303349
304350impl < In , Out , Param , Marker , F > IntoSystem < In , Out , ( IsFunctionSystem , Param , Marker ) > for F
@@ -366,13 +412,17 @@ where
366412 #[ inline]
367413 unsafe fn run_unsafe ( & mut self , input : Self :: In , world : & World ) -> Self :: Out {
368414 let change_tick = world. increment_change_tick ( ) ;
369- let out = self . func . run (
415+ // Trait disambiguation required here to disambiguate .run call
416+ // the .run found in the `RunnableSystem` trait
417+ let out = <F as SystemParamFunction < In , Out , Param , Marker > >:: run (
418+ & mut self . func ,
370419 input,
371420 self . param_state . as_mut ( ) . unwrap ( ) ,
372421 & self . system_meta ,
373422 world,
374423 change_tick,
375424 ) ;
425+
376426 self . system_meta . last_change_tick = change_tick;
377427 out
378428 }
0 commit comments