@@ -4,7 +4,7 @@ use bevy_ecs::{
4
4
prelude:: * ,
5
5
schedule:: {
6
6
apply_state_transition, common_conditions:: run_once as run_once_condition,
7
- run_enter_schedule, BoxedScheduleLabel , IntoSystemConfigs , IntoSystemSetConfigs ,
7
+ run_enter_schedule, InternedScheduleLabel , IntoSystemConfigs , IntoSystemSetConfigs ,
8
8
ScheduleLabel ,
9
9
} ,
10
10
} ;
@@ -70,7 +70,7 @@ pub struct App {
70
70
/// The schedule that runs the main loop of schedule execution.
71
71
///
72
72
/// This is initially set to [`Main`].
73
- pub main_schedule_label : BoxedScheduleLabel ,
73
+ pub main_schedule_label : InternedScheduleLabel ,
74
74
sub_apps : HashMap < AppLabelId , SubApp > ,
75
75
plugin_registry : Vec < Box < dyn Plugin > > ,
76
76
plugin_name_added : HashSet < String > ,
@@ -219,7 +219,7 @@ impl App {
219
219
sub_apps : HashMap :: default ( ) ,
220
220
plugin_registry : Vec :: default ( ) ,
221
221
plugin_name_added : Default :: default ( ) ,
222
- main_schedule_label : Box :: new ( Main ) ,
222
+ main_schedule_label : Main . into ( ) ,
223
223
building_plugin_depth : 0 ,
224
224
}
225
225
}
@@ -379,9 +379,10 @@ impl App {
379
379
schedule : impl ScheduleLabel ,
380
380
systems : impl IntoSystemConfigs < M > ,
381
381
) -> & mut Self {
382
+ let schedule: InternedScheduleLabel = ( & schedule as & dyn ScheduleLabel ) . into ( ) ;
382
383
let mut schedules = self . world . resource_mut :: < Schedules > ( ) ;
383
384
384
- if let Some ( schedule) = schedules. get_mut ( & schedule) {
385
+ if let Some ( schedule) = schedules. get_mut ( schedule) {
385
386
schedule. add_systems ( systems) ;
386
387
} else {
387
388
let mut new_schedule = Schedule :: new ( ) ;
@@ -398,8 +399,9 @@ impl App {
398
399
schedule : impl ScheduleLabel ,
399
400
set : impl IntoSystemSetConfig ,
400
401
) -> & mut Self {
402
+ let schedule: InternedScheduleLabel = ( & schedule as & dyn ScheduleLabel ) . into ( ) ;
401
403
let mut schedules = self . world . resource_mut :: < Schedules > ( ) ;
402
- if let Some ( schedule) = schedules. get_mut ( & schedule) {
404
+ if let Some ( schedule) = schedules. get_mut ( schedule) {
403
405
schedule. configure_set ( set) ;
404
406
} else {
405
407
let mut new_schedule = Schedule :: new ( ) ;
@@ -415,8 +417,9 @@ impl App {
415
417
schedule : impl ScheduleLabel ,
416
418
sets : impl IntoSystemSetConfigs ,
417
419
) -> & mut Self {
420
+ let schedule: InternedScheduleLabel = ( & schedule as & dyn ScheduleLabel ) . into ( ) ;
418
421
let mut schedules = self . world . resource_mut :: < Schedules > ( ) ;
419
- if let Some ( schedule) = schedules. get_mut ( & schedule) {
422
+ if let Some ( schedule) = schedules. get_mut ( schedule) {
420
423
schedule. configure_sets ( sets) ;
421
424
} else {
422
425
let mut new_schedule = Schedule :: new ( ) ;
@@ -797,7 +800,7 @@ impl App {
797
800
/// To avoid this behavior, use the `init_schedule` method instead.
798
801
pub fn add_schedule ( & mut self , label : impl ScheduleLabel , schedule : Schedule ) -> & mut Self {
799
802
let mut schedules = self . world . resource_mut :: < Schedules > ( ) ;
800
- schedules. insert ( label, schedule) ;
803
+ schedules. insert ( & label as & dyn ScheduleLabel , schedule) ;
801
804
802
805
self
803
806
}
@@ -806,8 +809,9 @@ impl App {
806
809
///
807
810
/// See [`App::add_schedule`] to pass in a pre-constructed schedule.
808
811
pub fn init_schedule ( & mut self , label : impl ScheduleLabel ) -> & mut Self {
812
+ let label: InternedScheduleLabel = ( & label as & dyn ScheduleLabel ) . into ( ) ;
809
813
let mut schedules = self . world . resource_mut :: < Schedules > ( ) ;
810
- if !schedules. contains ( & label) {
814
+ if !schedules. contains ( label) {
811
815
schedules. insert ( label, Schedule :: new ( ) ) ;
812
816
}
813
817
self
@@ -816,15 +820,15 @@ impl App {
816
820
/// Gets read-only access to the [`Schedule`] with the provided `label` if it exists.
817
821
pub fn get_schedule ( & self , label : impl ScheduleLabel ) -> Option < & Schedule > {
818
822
let schedules = self . world . get_resource :: < Schedules > ( ) ?;
819
- schedules. get ( & label)
823
+ schedules. get ( & label as & dyn ScheduleLabel )
820
824
}
821
825
822
826
/// Gets read-write access to a [`Schedule`] with the provided `label` if it exists.
823
827
pub fn get_schedule_mut ( & mut self , label : impl ScheduleLabel ) -> Option < & mut Schedule > {
824
828
let schedules = self . world . get_resource_mut :: < Schedules > ( ) ?;
825
829
// We need to call .into_inner here to satisfy the borrow checker:
826
830
// it can reason about reborrows using ordinary references but not the `Mut` smart pointer.
827
- schedules. into_inner ( ) . get_mut ( & label)
831
+ schedules. into_inner ( ) . get_mut ( & label as & dyn ScheduleLabel )
828
832
}
829
833
830
834
/// Applies the function to the [`Schedule`] associated with `label`.
@@ -835,13 +839,14 @@ impl App {
835
839
label : impl ScheduleLabel ,
836
840
f : impl FnOnce ( & mut Schedule ) ,
837
841
) -> & mut Self {
842
+ let label: InternedScheduleLabel = ( & label as & dyn ScheduleLabel ) . into ( ) ;
838
843
let mut schedules = self . world . resource_mut :: < Schedules > ( ) ;
839
844
840
- if schedules. get ( & label) . is_none ( ) {
841
- schedules. insert ( label. dyn_clone ( ) , Schedule :: new ( ) ) ;
845
+ if schedules. get ( label) . is_none ( ) {
846
+ schedules. insert ( label, Schedule :: new ( ) ) ;
842
847
}
843
848
844
- let schedule = schedules. get_mut ( & label) . unwrap ( ) ;
849
+ let schedule = schedules. get_mut ( label) . unwrap ( ) ;
845
850
// Call the function f, passing in the schedule retrieved
846
851
f ( schedule) ;
847
852
0 commit comments