@@ -2,7 +2,7 @@ use crate::bundle::Bundle;
2
2
use crate :: change_detection:: Mut ;
3
3
use crate :: entity:: Entity ;
4
4
use crate :: system:: input:: SystemInput ;
5
- use crate :: system:: { BoxedSystem , IntoSystem , System } ;
5
+ use crate :: system:: { BoxedSystem , IntoSystem , System , SystemIn } ;
6
6
use crate :: world:: { Command , World } ;
7
7
use crate :: { self as bevy_ecs} ;
8
8
use bevy_ecs_macros:: { Component , Resource } ;
@@ -365,10 +365,12 @@ impl World {
365
365
/// If you want to access values from the environment within a system, consider passing them in
366
366
/// as inputs via [`World::run_system_cached_with`]. If that's not an option, consider
367
367
/// [`World::register_system`] instead.
368
- pub fn register_system_cached < I : ' static , O : ' static , M , S : IntoSystem < I , O , M > + ' static > (
369
- & mut self ,
370
- system : S ,
371
- ) -> SystemId < I , O > {
368
+ pub fn register_system_cached < I , O , M , S > ( & mut self , system : S ) -> SystemId < I , O >
369
+ where
370
+ I : SystemInput + ' static ,
371
+ O : ' static ,
372
+ S : IntoSystem < I , O , M > + ' static ,
373
+ {
372
374
const {
373
375
assert ! (
374
376
size_of:: <S >( ) == 0 ,
@@ -397,10 +399,15 @@ impl World {
397
399
/// Removes a cached system and its [`CachedSystemId`] resource.
398
400
///
399
401
/// See [`World::register_system_cached`] for more information.
400
- pub fn remove_system_cached < I : ' static , O : ' static , M , S : IntoSystem < I , O , M > + ' static > (
402
+ pub fn remove_system_cached < I , O , M , S > (
401
403
& mut self ,
402
404
_system : S ,
403
- ) -> Result < RemovedSystem < I , O > , RegisteredSystemError < I , O > > {
405
+ ) -> Result < RemovedSystem < I , O > , RegisteredSystemError < I , O > >
406
+ where
407
+ I : SystemInput + ' static ,
408
+ O : ' static ,
409
+ S : IntoSystem < I , O , M > + ' static ,
410
+ {
404
411
let id = self
405
412
. remove_resource :: < CachedSystemId < S :: System > > ( )
406
413
. ok_or ( RegisteredSystemError :: SystemNotCached ) ?;
@@ -420,11 +427,16 @@ impl World {
420
427
/// Runs a cached system with an input, registering it if necessary.
421
428
///
422
429
/// See [`World::register_system_cached`] for more information.
423
- pub fn run_system_cached_with < I : ' static , O : ' static , M , S : IntoSystem < I , O , M > + ' static > (
430
+ pub fn run_system_cached_with < I , O , M , S > (
424
431
& mut self ,
425
432
system : S ,
426
- input : I ,
427
- ) -> Result < O , RegisteredSystemError < I , O > > {
433
+ input : I :: Inner < ' _ > ,
434
+ ) -> Result < O , RegisteredSystemError < I , O > >
435
+ where
436
+ I : SystemInput + ' static ,
437
+ O : ' static ,
438
+ S : IntoSystem < I , O , M > + ' static ,
439
+ {
428
440
let id = self . register_system_cached ( system) ;
429
441
self . run_system_with_input ( id, input)
430
442
}
@@ -525,13 +537,16 @@ where
525
537
/// See [`World::register_system_cached`] for more information.
526
538
pub struct RunSystemCachedWith < S : System < Out = ( ) > > {
527
539
system : S ,
528
- input : S :: In ,
540
+ input : SystemIn < ' static , S > ,
529
541
}
530
542
531
543
impl < S : System < Out = ( ) > > RunSystemCachedWith < S > {
532
544
/// Creates a new [`Command`] struct, which can be added to
533
545
/// [`Commands`](crate::system::Commands).
534
- pub fn new < M > ( system : impl IntoSystem < S :: In , ( ) , M , System = S > , input : S :: In ) -> Self {
546
+ pub fn new < M > (
547
+ system : impl IntoSystem < S :: In , ( ) , M , System = S > ,
548
+ input : SystemIn < ' static , S > ,
549
+ ) -> Self {
535
550
Self {
536
551
system : IntoSystem :: into_system ( system) ,
537
552
input,
@@ -541,7 +556,7 @@ impl<S: System<Out = ()>> RunSystemCachedWith<S> {
541
556
542
557
impl < S : System < Out = ( ) > > Command for RunSystemCachedWith < S >
543
558
where
544
- S :: In : Send ,
559
+ S :: In : SystemInput < Inner < ' static > : Send > ,
545
560
{
546
561
fn apply ( self , world : & mut World ) {
547
562
let _ = world. run_system_cached_with ( self . system , self . input ) ;
0 commit comments