Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document which lifetime is needed for systemparam derive #11321

Merged
merged 7 commits into from
Jan 22, 2024
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions crates/bevy_ecs/src/system/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,35 @@ use std::{
/// Derived `SystemParam` structs may have two lifetimes: `'w` for data stored in the [`World`],
/// and `'s` for data stored in the parameter's state.
///
/// The following list shows the most common SystemParams and which lifetime they require
alice-i-cecile marked this conversation as resolved.
Show resolved Hide resolved
///
/// ```
/// # use bevy_ecs::prelude::*;
/// # #[derive(Resource)]
/// # struct SomeResource;
/// # #[derive(Event)]
/// # struct SomeEvent;
/// # #[derive(Resource)]
/// # struct SomeOtherResource;
/// # use bevy_ecs::system::SystemParam;
/// # #[derive(SystemParam)]
/// # struct ParamsExample<'w, 's> {
/// # query:
/// Query<'w, 's, Entity>,
/// # res:
/// Res<'w, SomeResource>,
/// # res_mut:
/// ResMut<'w, SomeOtherResource>,
/// # local:
/// Local<'s, u8>,
/// # commands:
/// Commands<'w, 's>,
/// # eventreader:
/// EventReader<'w, 's, SomeEvent>,
/// # eventwriter:
/// EventWriter<'w, SomeEvent>
/// # }
///```
/// ## `PhantomData`
///
/// [`PhantomData`] is a special type of `SystemParam` that does nothing.
Expand Down
Loading