Skip to content

Commit

Permalink
AppExit documentation updates (bevyengine#7067) (bevyengine#7347)
Browse files Browse the repository at this point in the history
# Objective

Help users understand how to write code that runs when the app is exiting.

See:

- bevyengine#7067 (Partial resolution)

## Solution

Added documentation to `AppExit` class that mentions using the `Drop` trait for code that needs to run on program exit, as well as linking to the caveat about `App::run()` not being guaranteed to return.
  • Loading branch information
Testare authored and ItsDoot committed Feb 1, 2023
1 parent 7fc02b6 commit dd19c45
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,11 @@ fn run_once(mut app: App) {
///
/// You can also use this event to detect that an exit was requested. In order to receive it, systems
/// subscribing to this event should run after it was emitted and before the schedule of the same
/// frame is over.
/// frame is over. This is important since [`App::run()`] might never return.
///
/// If you don't require access to other components or resources, consider implementing the [`Drop`]
/// trait on components/resources for code that runs on exit. That saves you from worrying about
/// system schedule ordering, and is idiomatic Rust.
#[derive(Debug, Clone, Default)]
pub struct AppExit;

Expand Down

0 comments on commit dd19c45

Please sign in to comment.