@@ -1734,30 +1734,10 @@ impl World {
17341734 /// For other use cases, see the example on [`World::schedule_scope`].
17351735 pub fn try_schedule_scope < R > (
17361736 & mut self ,
1737- label : impl ScheduleLabel ,
1738- f : impl FnOnce ( & mut World , & mut Schedule ) -> R ,
1739- ) -> Result < R , TryRunScheduleError > {
1740- self . try_schedule_scope_ref ( & label, f)
1741- }
1742-
1743- /// Temporarily removes the schedule associated with `label` from the world,
1744- /// runs user code, and finally re-adds the schedule.
1745- /// This returns a [`TryRunScheduleError`] if there is no schedule
1746- /// associated with `label`.
1747- ///
1748- /// Unlike the `try_run_schedule` method, this method takes the label by reference, which can save a clone.
1749- ///
1750- /// The [`Schedule`] is fetched from the [`Schedules`] resource of the world by its label,
1751- /// and system state is cached.
1752- ///
1753- /// For simple cases where you just need to call the schedule once,
1754- /// consider using [`World::try_run_schedule_ref`] instead.
1755- /// For other use cases, see the example on [`World::schedule_scope`].
1756- pub fn try_schedule_scope_ref < R > (
1757- & mut self ,
1758- label : & dyn ScheduleLabel ,
1737+ label : impl AsRef < dyn ScheduleLabel > ,
17591738 f : impl FnOnce ( & mut World , & mut Schedule ) -> R ,
17601739 ) -> Result < R , TryRunScheduleError > {
1740+ let label = label. as_ref ( ) ;
17611741 let Some ( ( extracted_label, mut schedule) )
17621742 = self . get_resource_mut :: < Schedules > ( ) . and_then ( |mut s| s. remove_entry ( label) )
17631743 else {
@@ -1818,33 +1798,10 @@ impl World {
18181798 /// If the requested schedule does not exist.
18191799 pub fn schedule_scope < R > (
18201800 & mut self ,
1821- label : impl ScheduleLabel ,
1822- f : impl FnOnce ( & mut World , & mut Schedule ) -> R ,
1823- ) -> R {
1824- self . schedule_scope_ref ( & label, f)
1825- }
1826-
1827- /// Temporarily removes the schedule associated with `label` from the world,
1828- /// runs user code, and finally re-adds the schedule.
1829- ///
1830- /// Unlike the `run_schedule` method, this method takes the label by reference, which can save a clone.
1831- ///
1832- /// The [`Schedule`] is fetched from the [`Schedules`] resource of the world by its label,
1833- /// and system state is cached.
1834- ///
1835- /// For simple cases where you just need to call the schedule,
1836- /// consider using [`World::run_schedule_ref`] instead.
1837- /// For other use cases, see the example on [`World::schedule_scope`].
1838- ///
1839- /// # Panics
1840- ///
1841- /// If the requested schedule does not exist.
1842- pub fn schedule_scope_ref < R > (
1843- & mut self ,
1844- label : & dyn ScheduleLabel ,
1801+ label : impl AsRef < dyn ScheduleLabel > ,
18451802 f : impl FnOnce ( & mut World , & mut Schedule ) -> R ,
18461803 ) -> R {
1847- self . try_schedule_scope_ref ( label, f)
1804+ self . try_schedule_scope ( label, f)
18481805 . unwrap_or_else ( |e| panic ! ( "{e}" ) )
18491806 }
18501807
@@ -1857,25 +1814,9 @@ impl World {
18571814 /// For simple testing use cases, call [`Schedule::run(&mut world)`](Schedule::run) instead.
18581815 pub fn try_run_schedule (
18591816 & mut self ,
1860- label : impl ScheduleLabel ,
1861- ) -> Result < ( ) , TryRunScheduleError > {
1862- self . try_run_schedule_ref ( & label)
1863- }
1864-
1865- /// Attempts to run the [`Schedule`] associated with the `label` a single time,
1866- /// and returns a [`TryRunScheduleError`] if the schedule does not exist.
1867- ///
1868- /// Unlike the `try_run_schedule` method, this method takes the label by reference, which can save a clone.
1869- ///
1870- /// The [`Schedule`] is fetched from the [`Schedules`] resource of the world by its label,
1871- /// and system state is cached.
1872- ///
1873- /// For simple testing use cases, call [`Schedule::run(&mut world)`](Schedule::run) instead.
1874- pub fn try_run_schedule_ref (
1875- & mut self ,
1876- label : & dyn ScheduleLabel ,
1817+ label : impl AsRef < dyn ScheduleLabel > ,
18771818 ) -> Result < ( ) , TryRunScheduleError > {
1878- self . try_schedule_scope_ref ( label, |world, sched| sched. run ( world) )
1819+ self . try_schedule_scope ( label, |world, sched| sched. run ( world) )
18791820 }
18801821
18811822 /// Runs the [`Schedule`] associated with the `label` a single time.
@@ -1888,8 +1829,8 @@ impl World {
18881829 /// # Panics
18891830 ///
18901831 /// If the requested schedule does not exist.
1891- pub fn run_schedule ( & mut self , label : impl ScheduleLabel ) {
1892- self . run_schedule_ref ( & label) ;
1832+ pub fn run_schedule ( & mut self , label : impl AsRef < dyn ScheduleLabel > ) {
1833+ self . schedule_scope ( label, |world , sched| sched . run ( world ) ) ;
18931834 }
18941835
18951836 /// Runs the [`Schedule`] associated with the `label` a single time.
@@ -1904,8 +1845,9 @@ impl World {
19041845 /// # Panics
19051846 ///
19061847 /// If the requested schedule does not exist.
1848+ #[ deprecated = "Use `World::run_schedule` instead." ]
19071849 pub fn run_schedule_ref ( & mut self , label : & dyn ScheduleLabel ) {
1908- self . schedule_scope_ref ( label, |world, sched| sched. run ( world) ) ;
1850+ self . schedule_scope ( label, |world, sched| sched. run ( world) ) ;
19091851 }
19101852}
19111853
0 commit comments