From 49930369b4c6d47e4c5db164633debcefed88b1a Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Sun, 16 Apr 2023 09:29:56 -0400 Subject: [PATCH 01/11] merge `ref` variants of schedule methods with the owned versions --- crates/bevy_ecs/src/world/mod.rs | 86 ++------------------------------ 1 file changed, 5 insertions(+), 81 deletions(-) diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index c14b4ab8d4e90..4126f153198e7 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -1730,30 +1730,9 @@ impl World { /// and system state is cached. /// /// For simple cases where you just need to call the schedule once, - /// consider using [`World::try_run_schedule`] instead. - /// For other use cases, see the example on [`World::schedule_scope`]. - pub fn try_schedule_scope( - &mut self, - label: impl ScheduleLabel, - f: impl FnOnce(&mut World, &mut Schedule) -> R, - ) -> Result { - self.try_schedule_scope_ref(&label, f) - } - - /// Temporarily removes the schedule associated with `label` from the world, - /// runs user code, and finally re-adds the schedule. - /// This returns a [`TryRunScheduleError`] if there is no schedule - /// associated with `label`. - /// - /// Unlike the `try_run_schedule` method, this method takes the label by reference, which can save a clone. - /// - /// The [`Schedule`] is fetched from the [`Schedules`] resource of the world by its label, - /// and system state is cached. - /// - /// For simple cases where you just need to call the schedule once, /// consider using [`World::try_run_schedule_ref`] instead. /// For other use cases, see the example on [`World::schedule_scope`]. - pub fn try_schedule_scope_ref( + pub fn try_schedule_scope( &mut self, label: &dyn ScheduleLabel, f: impl FnOnce(&mut World, &mut Schedule) -> R, @@ -1817,34 +1796,11 @@ impl World { /// /// If the requested schedule does not exist. pub fn schedule_scope( - &mut self, - label: impl ScheduleLabel, - f: impl FnOnce(&mut World, &mut Schedule) -> R, - ) -> R { - self.schedule_scope_ref(&label, f) - } - - /// Temporarily removes the schedule associated with `label` from the world, - /// runs user code, and finally re-adds the schedule. - /// - /// Unlike the `run_schedule` method, this method takes the label by reference, which can save a clone. - /// - /// The [`Schedule`] is fetched from the [`Schedules`] resource of the world by its label, - /// and system state is cached. - /// - /// For simple cases where you just need to call the schedule, - /// consider using [`World::run_schedule_ref`] instead. - /// For other use cases, see the example on [`World::schedule_scope`]. - /// - /// # Panics - /// - /// If the requested schedule does not exist. - pub fn schedule_scope_ref( &mut self, label: &dyn ScheduleLabel, f: impl FnOnce(&mut World, &mut Schedule) -> R, ) -> R { - self.try_schedule_scope_ref(label, f) + self.try_schedule_scope(label, f) .unwrap_or_else(|e| panic!("{e}")) } @@ -1856,26 +1812,10 @@ impl World { /// /// For simple testing use cases, call [`Schedule::run(&mut world)`](Schedule::run) instead. pub fn try_run_schedule( - &mut self, - label: impl ScheduleLabel, - ) -> Result<(), TryRunScheduleError> { - self.try_run_schedule_ref(&label) - } - - /// Attempts to run the [`Schedule`] associated with the `label` a single time, - /// and returns a [`TryRunScheduleError`] if the schedule does not exist. - /// - /// Unlike the `try_run_schedule` method, this method takes the label by reference, which can save a clone. - /// - /// The [`Schedule`] is fetched from the [`Schedules`] resource of the world by its label, - /// and system state is cached. - /// - /// For simple testing use cases, call [`Schedule::run(&mut world)`](Schedule::run) instead. - pub fn try_run_schedule_ref( &mut self, label: &dyn ScheduleLabel, ) -> Result<(), TryRunScheduleError> { - self.try_schedule_scope_ref(label, |world, sched| sched.run(world)) + self.try_schedule_scope(label, |world, sched| sched.run(world)) } /// Runs the [`Schedule`] associated with the `label` a single time. @@ -1888,24 +1828,8 @@ impl World { /// # Panics /// /// If the requested schedule does not exist. - pub fn run_schedule(&mut self, label: impl ScheduleLabel) { - self.run_schedule_ref(&label); - } - - /// Runs the [`Schedule`] associated with the `label` a single time. - /// - /// Unlike the `run_schedule` method, this method takes the label by reference, which can save a clone. - /// - /// The [`Schedule`] is fetched from the [`Schedules`] resource of the world by its label, - /// and system state is cached. - /// - /// For simple testing use cases, call [`Schedule::run(&mut world)`](Schedule::run) instead. - /// - /// # Panics - /// - /// If the requested schedule does not exist. - pub fn run_schedule_ref(&mut self, label: &dyn ScheduleLabel) { - self.schedule_scope_ref(label, |world, sched| sched.run(world)); + pub fn run_schedule(&mut self, label: &dyn ScheduleLabel) { + self.schedule_scope(label, |world, sched| sched.run(world)); } } From 8519141f4eb7d1f81499703dd6028ccb8e5ce719 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Sun, 16 Apr 2023 09:38:11 -0400 Subject: [PATCH 02/11] update callsites --- crates/bevy_app/src/app.rs | 10 ++++------ crates/bevy_app/src/main_schedule.rs | 8 ++++---- crates/bevy_ecs/src/schedule/state.rs | 8 ++++---- crates/bevy_render/src/lib.rs | 2 +- crates/bevy_time/src/fixed_timestep.rs | 2 +- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index ae1efa7694334..dc769bb3a7edc 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -162,9 +162,7 @@ impl SubApp { /// Runs the `SubApp`'s default schedule. pub fn run(&mut self) { - self.app - .world - .run_schedule_ref(&*self.app.main_schedule_label); + self.app.world.run_schedule(&*self.app.main_schedule_label); self.app.world.clear_trackers(); } @@ -241,7 +239,7 @@ impl App { { #[cfg(feature = "trace")] let _bevy_frame_update_span = info_span!("main app").entered(); - self.world.run_schedule_ref(&*self.main_schedule_label); + self.world.run_schedule(&*self.main_schedule_label); } for (_label, sub_app) in self.sub_apps.iter_mut() { #[cfg(feature = "trace")] @@ -1025,7 +1023,7 @@ mod tests { app.add_state::() .add_systems(OnEnter(AppState::MainMenu), (foo, bar)); - app.world.run_schedule(OnEnter(AppState::MainMenu)); + app.world.run_schedule(&OnEnter(AppState::MainMenu)); assert_eq!(app.world.entities().len(), 2); } @@ -1035,7 +1033,7 @@ mod tests { app.add_systems(OnEnter(AppState::MainMenu), (foo, bar)) .add_state::(); - app.world.run_schedule(OnEnter(AppState::MainMenu)); + app.world.run_schedule(&OnEnter(AppState::MainMenu)); assert_eq!(app.world.entities().len(), 2); } } diff --git a/crates/bevy_app/src/main_schedule.rs b/crates/bevy_app/src/main_schedule.rs index 2042b9e01f4e8..4b84b00fc652b 100644 --- a/crates/bevy_app/src/main_schedule.rs +++ b/crates/bevy_app/src/main_schedule.rs @@ -135,15 +135,15 @@ impl Main { /// A system that runs the "main schedule" pub fn run_main(world: &mut World, mut run_at_least_once: Local) { if !*run_at_least_once { - let _ = world.try_run_schedule(PreStartup); - let _ = world.try_run_schedule(Startup); - let _ = world.try_run_schedule(PostStartup); + let _ = world.try_run_schedule(&PreStartup); + let _ = world.try_run_schedule(&Startup); + let _ = world.try_run_schedule(&PostStartup); *run_at_least_once = true; } world.resource_scope(|world, order: Mut| { for label in &order.labels { - let _ = world.try_run_schedule_ref(&**label); + let _ = world.try_run_schedule(&**label); } }); } diff --git a/crates/bevy_ecs/src/schedule/state.rs b/crates/bevy_ecs/src/schedule/state.rs index 763198aa0f8e7..ececd6b5b5d5d 100644 --- a/crates/bevy_ecs/src/schedule/state.rs +++ b/crates/bevy_ecs/src/schedule/state.rs @@ -113,7 +113,7 @@ impl NextState { /// Run the enter schedule (if it exists) for the current state. pub fn run_enter_schedule(world: &mut World) { world - .try_run_schedule(OnEnter(world.resource::>().0.clone())) + .try_run_schedule(&OnEnter(world.resource::>().0.clone())) .ok(); } @@ -133,14 +133,14 @@ pub fn apply_state_transition(world: &mut World) { if *state_resource != entered { let exited = mem::replace(&mut state_resource.0, entered.clone()); // Try to run the schedules if they exist. - world.try_run_schedule(OnExit(exited.clone())).ok(); + world.try_run_schedule(&OnExit(exited.clone())).ok(); world - .try_run_schedule(OnTransition { + .try_run_schedule(&OnTransition { from: exited, to: entered.clone(), }) .ok(); - world.try_run_schedule(OnEnter(entered)).ok(); + world.try_run_schedule(&OnEnter(entered)).ok(); } } } diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 6c852239c41f0..304f7b20da55b 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -330,7 +330,7 @@ fn extract(main_world: &mut World, render_app: &mut App) { let inserted_world = std::mem::replace(main_world, scratch_world.0); render_app.world.insert_resource(MainWorld(inserted_world)); - render_app.world.run_schedule(ExtractSchedule); + render_app.world.run_schedule(&ExtractSchedule); // move the app world back, as if nothing happened. let inserted_world = render_app.world.remove_resource::().unwrap(); diff --git a/crates/bevy_time/src/fixed_timestep.rs b/crates/bevy_time/src/fixed_timestep.rs index 66be2f41ef2ff..dc47e9b2548a9 100644 --- a/crates/bevy_time/src/fixed_timestep.rs +++ b/crates/bevy_time/src/fixed_timestep.rs @@ -107,7 +107,7 @@ pub fn run_fixed_update_schedule(world: &mut World) { fixed_time.tick(delta_time); // Run the schedule until we run out of accumulated time - let _ = world.try_schedule_scope(FixedUpdate, |world, schedule| { + let _ = world.try_schedule_scope(&FixedUpdate, |world, schedule| { while world.resource_mut::().expend().is_ok() { schedule.run(world); } From 6cee24f13ae5eafe5fca03c60d8e9975245d4dec Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Sun, 16 Apr 2023 09:56:15 -0400 Subject: [PATCH 03/11] update a doctest --- crates/bevy_ecs/src/world/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index 4126f153198e7..daa0d9d60af3e 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -1781,7 +1781,7 @@ impl World { /// # world.add_schedule(schedule, MySchedule); /// # fn tick_counter(mut counter: ResMut) { counter.0 += 1; } /// // Run the schedule five times. - /// world.schedule_scope(MySchedule, |world, schedule| { + /// world.schedule_scope(&MySchedule, |world, schedule| { /// for _ in 0..5 { /// schedule.run(world); /// } From 9faae3ec89cd291222f46e2a8c7c5c141558a2c1 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Sun, 16 Apr 2023 18:16:28 -0400 Subject: [PATCH 04/11] update another doctest --- crates/bevy_ecs/src/world/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index daa0d9d60af3e..cf7182ecb2f25 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -1730,7 +1730,7 @@ impl World { /// and system state is cached. /// /// For simple cases where you just need to call the schedule once, - /// consider using [`World::try_run_schedule_ref`] instead. + /// consider using [`World::try_run_schedule`] instead. /// For other use cases, see the example on [`World::schedule_scope`]. pub fn try_schedule_scope( &mut self, From 7b21505f7e4ef5b3f0365e702566c4946aac129f Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Tue, 18 Apr 2023 23:50:51 -0400 Subject: [PATCH 05/11] update a unit test --- crates/bevy_ecs/src/schedule/set.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/schedule/set.rs b/crates/bevy_ecs/src/schedule/set.rs index 1e00a039a5792..590dfc6ee6f0f 100644 --- a/crates/bevy_ecs/src/schedule/set.rs +++ b/crates/bevy_ecs/src/schedule/set.rs @@ -201,7 +201,7 @@ mod tests { let boxed: Box = Box::new(A); world.insert_resource(Flag(false)); - world.run_schedule_ref(&boxed); + world.run_schedule(&boxed); assert!(world.resource::().0); world.insert_resource(Flag(false)); From ad3df3df10725d3ae7c9e774b72fa0aae13b1343 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Tue, 18 Apr 2023 23:51:27 -0400 Subject: [PATCH 06/11] implement `AsRef` for `ScheduleLabel` types --- crates/bevy_macro_utils/src/lib.rs | 6 ++++++ crates/bevy_utils/src/label.rs | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/crates/bevy_macro_utils/src/lib.rs b/crates/bevy_macro_utils/src/lib.rs index 212a78ce3d69b..0aeea189448b4 100644 --- a/crates/bevy_macro_utils/src/lib.rs +++ b/crates/bevy_macro_utils/src/lib.rs @@ -191,6 +191,12 @@ pub fn derive_boxed_label(input: syn::DeriveInput, trait_path: &syn::Path) -> To ::std::hash::Hash::hash(self, &mut state); } } + + impl #impl_generics ::std::convert::AsRef for #ident #ty_generics #where_clause { + fn as_ref(&self) -> &dyn #trait_path { + self + } + } }) .into() } diff --git a/crates/bevy_utils/src/label.rs b/crates/bevy_utils/src/label.rs index 3c0fb762d9619..6eff79c0bb389 100644 --- a/crates/bevy_utils/src/label.rs +++ b/crates/bevy_utils/src/label.rs @@ -111,6 +111,13 @@ macro_rules! define_boxed_label { } } + impl ::std::convert::AsRef for dyn $label_trait_name { + #[inline] + fn as_ref(&self) -> &Self { + self + } + } + impl Clone for Box { fn clone(&self) -> Self { self.dyn_clone() From 63516f1cb312a5106092d654e27e698c12d33954 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Tue, 18 Apr 2023 23:54:09 -0400 Subject: [PATCH 07/11] use `AsRef` for world schedule methods --- crates/bevy_app/src/main_schedule.rs | 6 +++--- crates/bevy_ecs/src/world/mod.rs | 9 +++++---- crates/bevy_time/src/fixed_timestep.rs | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/bevy_app/src/main_schedule.rs b/crates/bevy_app/src/main_schedule.rs index 4b84b00fc652b..c940fda5337b9 100644 --- a/crates/bevy_app/src/main_schedule.rs +++ b/crates/bevy_app/src/main_schedule.rs @@ -135,9 +135,9 @@ impl Main { /// A system that runs the "main schedule" pub fn run_main(world: &mut World, mut run_at_least_once: Local) { if !*run_at_least_once { - let _ = world.try_run_schedule(&PreStartup); - let _ = world.try_run_schedule(&Startup); - let _ = world.try_run_schedule(&PostStartup); + let _ = world.try_run_schedule(PreStartup); + let _ = world.try_run_schedule(Startup); + let _ = world.try_run_schedule(PostStartup); *run_at_least_once = true; } diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index cf7182ecb2f25..cc1df1bcac8db 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -1734,9 +1734,10 @@ impl World { /// For other use cases, see the example on [`World::schedule_scope`]. pub fn try_schedule_scope( &mut self, - label: &dyn ScheduleLabel, + label: impl AsRef, f: impl FnOnce(&mut World, &mut Schedule) -> R, ) -> Result { + let label = label.as_ref(); let Some((extracted_label, mut schedule)) = self.get_resource_mut::().and_then(|mut s| s.remove_entry(label)) else { @@ -1797,7 +1798,7 @@ impl World { /// If the requested schedule does not exist. pub fn schedule_scope( &mut self, - label: &dyn ScheduleLabel, + label: impl AsRef, f: impl FnOnce(&mut World, &mut Schedule) -> R, ) -> R { self.try_schedule_scope(label, f) @@ -1813,7 +1814,7 @@ impl World { /// For simple testing use cases, call [`Schedule::run(&mut world)`](Schedule::run) instead. pub fn try_run_schedule( &mut self, - label: &dyn ScheduleLabel, + label: impl AsRef, ) -> Result<(), TryRunScheduleError> { self.try_schedule_scope(label, |world, sched| sched.run(world)) } @@ -1828,7 +1829,7 @@ impl World { /// # Panics /// /// If the requested schedule does not exist. - pub fn run_schedule(&mut self, label: &dyn ScheduleLabel) { + pub fn run_schedule(&mut self, label: impl AsRef) { self.schedule_scope(label, |world, sched| sched.run(world)); } } diff --git a/crates/bevy_time/src/fixed_timestep.rs b/crates/bevy_time/src/fixed_timestep.rs index dc47e9b2548a9..66be2f41ef2ff 100644 --- a/crates/bevy_time/src/fixed_timestep.rs +++ b/crates/bevy_time/src/fixed_timestep.rs @@ -107,7 +107,7 @@ pub fn run_fixed_update_schedule(world: &mut World) { fixed_time.tick(delta_time); // Run the schedule until we run out of accumulated time - let _ = world.try_schedule_scope(&FixedUpdate, |world, schedule| { + let _ = world.try_schedule_scope(FixedUpdate, |world, schedule| { while world.resource_mut::().expend().is_ok() { schedule.run(world); } From 4ab93d4883c379102fdbfbb705be4689f1680663 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Tue, 18 Apr 2023 23:55:00 -0400 Subject: [PATCH 08/11] update a doctest --- crates/bevy_ecs/src/world/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index cc1df1bcac8db..0c20ea59ae719 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -1782,7 +1782,7 @@ impl World { /// # world.add_schedule(schedule, MySchedule); /// # fn tick_counter(mut counter: ResMut) { counter.0 += 1; } /// // Run the schedule five times. - /// world.schedule_scope(&MySchedule, |world, schedule| { + /// world.schedule_scope(MySchedule, |world, schedule| { /// for _ in 0..5 { /// schedule.run(world); /// } From de78ecb37caa9fb57dc8345f450bb5e8ddbb258b Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Tue, 18 Apr 2023 23:58:59 -0400 Subject: [PATCH 09/11] revert some changes --- crates/bevy_app/src/app.rs | 4 ++-- crates/bevy_ecs/src/schedule/state.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index dc769bb3a7edc..33cc26ca739c9 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -1023,7 +1023,7 @@ mod tests { app.add_state::() .add_systems(OnEnter(AppState::MainMenu), (foo, bar)); - app.world.run_schedule(&OnEnter(AppState::MainMenu)); + app.world.run_schedule(OnEnter(AppState::MainMenu)); assert_eq!(app.world.entities().len(), 2); } @@ -1033,7 +1033,7 @@ mod tests { app.add_systems(OnEnter(AppState::MainMenu), (foo, bar)) .add_state::(); - app.world.run_schedule(&OnEnter(AppState::MainMenu)); + app.world.run_schedule(OnEnter(AppState::MainMenu)); assert_eq!(app.world.entities().len(), 2); } } diff --git a/crates/bevy_ecs/src/schedule/state.rs b/crates/bevy_ecs/src/schedule/state.rs index ececd6b5b5d5d..763198aa0f8e7 100644 --- a/crates/bevy_ecs/src/schedule/state.rs +++ b/crates/bevy_ecs/src/schedule/state.rs @@ -113,7 +113,7 @@ impl NextState { /// Run the enter schedule (if it exists) for the current state. pub fn run_enter_schedule(world: &mut World) { world - .try_run_schedule(&OnEnter(world.resource::>().0.clone())) + .try_run_schedule(OnEnter(world.resource::>().0.clone())) .ok(); } @@ -133,14 +133,14 @@ pub fn apply_state_transition(world: &mut World) { if *state_resource != entered { let exited = mem::replace(&mut state_resource.0, entered.clone()); // Try to run the schedules if they exist. - world.try_run_schedule(&OnExit(exited.clone())).ok(); + world.try_run_schedule(OnExit(exited.clone())).ok(); world - .try_run_schedule(&OnTransition { + .try_run_schedule(OnTransition { from: exited, to: entered.clone(), }) .ok(); - world.try_run_schedule(&OnEnter(entered)).ok(); + world.try_run_schedule(OnEnter(entered)).ok(); } } } From d58a6ffa4bbdf795c3f14c51565305661748ef13 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Wed, 19 Apr 2023 00:08:17 -0400 Subject: [PATCH 10/11] deprecate `run_schedule_ref` --- crates/bevy_ecs/src/world/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index 0c20ea59ae719..943bb04c7f6ee 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -1832,6 +1832,23 @@ impl World { pub fn run_schedule(&mut self, label: impl AsRef) { self.schedule_scope(label, |world, sched| sched.run(world)); } + + /// Runs the [`Schedule`] associated with the `label` a single time. + /// + /// Unlike the `run_schedule` method, this method takes the label by reference, which can save a clone. + /// + /// The [`Schedule`] is fetched from the [`Schedules`] resource of the world by its label, + /// and system state is cached. + /// + /// For simple testing use cases, call [`Schedule::run(&mut world)`](Schedule::run) instead. + /// + /// # Panics + /// + /// If the requested schedule does not exist. + #[deprecated = "Use `World::run_schedule` instead."] + pub fn run_schedule_ref(&mut self, label: &dyn ScheduleLabel) { + self.schedule_scope(label, |world, sched| sched.run(world)); + } } impl fmt::Debug for World { From bf312818525c5f9e03531a3d8d22e662f752efeb Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Wed, 19 Apr 2023 00:13:19 -0400 Subject: [PATCH 11/11] revert another change --- crates/bevy_render/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 304f7b20da55b..6c852239c41f0 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -330,7 +330,7 @@ fn extract(main_world: &mut World, render_app: &mut App) { let inserted_world = std::mem::replace(main_world, scratch_world.0); render_app.world.insert_resource(MainWorld(inserted_world)); - render_app.world.run_schedule(&ExtractSchedule); + render_app.world.run_schedule(ExtractSchedule); // move the app world back, as if nothing happened. let inserted_world = render_app.world.remove_resource::().unwrap();