Hey all, I am trying to write a simple function to check if an app already has a system added, but for the life of me cannot get the default schedule from a reference to the app:
My code:
fn app_contains_system(app: &App, system: &SystemAppConfig) -> bool {
let schedules = app.world.resource::<Schedules>();
let schedule_label = &*app.default_schedule_label;
if let Some(default_schedule) = schedules.get(schedule_label) {
return default_schedule
.graph()
.systems()
.find(|s| s.type_id() == system.type_id())
.is_some();
} else {
panic!("Default schedule does not exist.");
}
}
This throws the error:
|
144 | fn app_contains_system(app: &App, system: &SystemAppConfig) -> bool {
| --- - let's call the lifetime of this reference `'1`
| |
| `app` is a reference that is only valid in the function body
...
148 | if let Some(default_schedule) = schedules.get(schedule_label) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `app` escapes the function body here
| argument requires that `'1` must outlive `'static`
Does anyone know how I would be able to get around this?