@@ -1734,30 +1734,10 @@ impl World {
1734
1734
/// For other use cases, see the example on [`World::schedule_scope`].
1735
1735
pub fn try_schedule_scope < R > (
1736
1736
& 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 > ,
1759
1738
f : impl FnOnce ( & mut World , & mut Schedule ) -> R ,
1760
1739
) -> Result < R , TryRunScheduleError > {
1740
+ let label = label. as_ref ( ) ;
1761
1741
let Some ( ( extracted_label, mut schedule) )
1762
1742
= self . get_resource_mut :: < Schedules > ( ) . and_then ( |mut s| s. remove_entry ( label) )
1763
1743
else {
@@ -1818,33 +1798,10 @@ impl World {
1818
1798
/// If the requested schedule does not exist.
1819
1799
pub fn schedule_scope < R > (
1820
1800
& 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 > ,
1845
1802
f : impl FnOnce ( & mut World , & mut Schedule ) -> R ,
1846
1803
) -> R {
1847
- self . try_schedule_scope_ref ( label, f)
1804
+ self . try_schedule_scope ( label, f)
1848
1805
. unwrap_or_else ( |e| panic ! ( "{e}" ) )
1849
1806
}
1850
1807
@@ -1857,25 +1814,9 @@ impl World {
1857
1814
/// For simple testing use cases, call [`Schedule::run(&mut world)`](Schedule::run) instead.
1858
1815
pub fn try_run_schedule (
1859
1816
& 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 > ,
1877
1818
) -> 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) )
1879
1820
}
1880
1821
1881
1822
/// Runs the [`Schedule`] associated with the `label` a single time.
@@ -1888,8 +1829,8 @@ impl World {
1888
1829
/// # Panics
1889
1830
///
1890
1831
/// 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 ) ) ;
1893
1834
}
1894
1835
1895
1836
/// Runs the [`Schedule`] associated with the `label` a single time.
@@ -1904,8 +1845,9 @@ impl World {
1904
1845
/// # Panics
1905
1846
///
1906
1847
/// If the requested schedule does not exist.
1848
+ #[ deprecated = "Use `World::run_schedule` instead." ]
1907
1849
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) ) ;
1909
1851
}
1910
1852
}
1911
1853
0 commit comments