Skip to content

Commit

Permalink
initialize Schedules if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
JoJoJet committed Apr 12, 2023
1 parent 70333b1 commit 0e61de6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/bevy_ecs/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,9 @@ impl World {
label: &dyn ScheduleLabel,
f: impl FnOnce(&mut World, &mut Schedule) -> R,
) -> Result<R, ScheduleNotFoundError> {
let Some((extracted_label, mut schedule)) = self.resource_mut::<Schedules>().remove_entry(label) else {
let Some((extracted_label, mut schedule))
= self.get_resource_or_insert_with(Schedules::default).remove_entry(label)
else {
return Err(ScheduleNotFoundError(label.dyn_clone()));
};

Expand Down

0 comments on commit 0e61de6

Please sign in to comment.