Skip to content

Commit ef8746a

Browse files
committed
AppExit documentation updates (#7067) (#7347)
# Objective Help users understand how to write code that runs when the app is exiting. See: - #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.
1 parent e84907f commit ef8746a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/bevy_app/src/app.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,11 @@ fn run_once(mut app: App) {
11661166
///
11671167
/// You can also use this event to detect that an exit was requested. In order to receive it, systems
11681168
/// subscribing to this event should run after it was emitted and before the schedule of the same
1169-
/// frame is over.
1169+
/// frame is over. This is important since [`App::run()`] might never return.
1170+
///
1171+
/// If you don't require access to other components or resources, consider implementing the [`Drop`]
1172+
/// trait on components/resources for code that runs on exit. That saves you from worrying about
1173+
/// system schedule ordering, and is idiomatic Rust.
11701174
#[derive(Debug, Clone, Default)]
11711175
pub struct AppExit;
11721176

0 commit comments

Comments
 (0)