From f9180685daa51bf59f67c4adc266d7d09f72ca20 Mon Sep 17 00:00:00 2001 From: MichiRecRoom <1008889+LikeLakers2@users.noreply.github.com> Date: Tue, 24 Dec 2024 01:15:16 -0500 Subject: [PATCH] Expose access to `SubApps` within `App` (#16952) # Objective `SubApps` is visible within the documentation for `bevy_app`. However, no way of accessing the `SubApps` field in `App` is currently available. ## Solution Expose two new functions, `App::sub_apps()` and `App::sub_apps_mut()`, which give immutable and mutable access to `SubApps` respectively. The other solution is to hide `SubApps`, which I submitted as a PR at . ## Testing Because of the simplicity of the changes, I only tested by compiling `bevy_app` - which compiled successfully. Note: `SubApps`, and its corresponding field on `App`, are not used outside of `bevy_app` - which means that compiling the other crates is not necessary. --- crates/bevy_app/src/app.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index a755b978ed081..aa6dfb62e99cd 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -1058,6 +1058,16 @@ impl App { &mut self.sub_apps.main } + /// Returns a reference to the [`SubApps`] collection. + pub fn sub_apps(&self) -> &SubApps { + &self.sub_apps + } + + /// Returns a mutable reference to the [`SubApps`] collection. + pub fn sub_apps_mut(&mut self) -> &mut SubApps { + &mut self.sub_apps + } + /// Returns a reference to the [`SubApp`] with the given label. /// /// # Panics