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
<https://github.com/bevyengine/bevy/pull/16953>.

## 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.
This commit is contained in:
MichiRecRoom 2024-12-24 01:15:16 -05:00 committed by GitHub
parent 4acb34ee34
commit 4a681c3f05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1058,6 +1058,16 @@ impl App {
&mut self.sub_apps.main &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. /// Returns a reference to the [`SubApp`] with the given label.
/// ///
/// # Panics /// # Panics