Skip to content

Commit

Permalink
Clarify that bevy_app::App.world() (and mut variant) returns the ma…
Browse files Browse the repository at this point in the history
…in `SubApp`'s `World` (#16527)

# Objective
The documentation for `bevy_app::App.world()` (and its mut variant)
could confuse some into thinking that this is the only World that the
App will contain.

## Solution
Clarify the documentation for `bevy_app::App.world()` (and its mut
variant), to say that it returns the main subapp's world. This helps
imply that Apps can contain more than one world (albeit, only one per
SubApp).

## Testing
This is a documentation change, with no changes to doctests. Thus,
testing is not necessary beyond ensuring the link syntax is correct.
  • Loading branch information
LikeLakers2 authored and mockersf committed Nov 27, 2024
1 parent c245be0 commit cf2145c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,12 +1008,18 @@ impl App {
.try_register_required_components_with::<T, R>(constructor)
}

/// Returns a reference to the [`World`].
/// Returns a reference to the main [`SubApp`]'s [`World`]. This is the same as calling
/// [`app.main().world()`].
///
/// [`app.main().world()`]: SubApp::world
pub fn world(&self) -> &World {
self.main().world()
}

/// Returns a mutable reference to the [`World`].
/// Returns a mutable reference to the main [`SubApp`]'s [`World`]. This is the same as calling
/// [`app.main_mut().world_mut()`].
///
/// [`app.main_mut().world_mut()`]: SubApp::world_mut
pub fn world_mut(&mut self) -> &mut World {
self.main_mut().world_mut()
}
Expand Down

0 comments on commit cf2145c

Please sign in to comment.