Skip to content

Commit

Permalink
add docs for the new attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
JoJoJet committed Dec 29, 2022
1 parent 28bd174 commit c48b67f
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion crates/bevy_ecs/src/system/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use std::{
/// will be created with the default value upon realisation.
/// This is most useful for `PhantomData` fields, such as markers for generic types.
///
/// # Example
/// ### Example
///
/// ```
/// # use bevy_ecs::prelude::*;
Expand All @@ -66,6 +66,29 @@ use std::{
/// # bevy_ecs::system::assert_is_system(my_system::<()>);
/// ```
///
/// `#[system_param(read_only)]` and `#[system_param(mutable)]`:
/// Can be placed on the struct definition to indicate whether or not the type should
/// implement [`ReadOnlySystemParam`].
/// In most cases you do not need to worry about either of these attributes, since derived
/// `SystemParam`s automatically implement `ReadOnlySystemParam` if each field does.
///
/// However, it is necessary to manually specifify this when you need to encapsulate
/// private fields, since the default automagic `ReadOnlySystemParam` impl publicly
/// exposes the type of each field.
///
/// ### Example
///
/// ```
/// # use bevy_ecs::prelude::*;
/// # use bevy_ecs_macros::SystemParam;
/// #[derive(Resource)]
/// struct MyResource(u32);
///
/// #[derive(SystemParam)]
/// #[system_param(mutable)] // `MyResource` gets leaked if you don't add this
/// pub struct MyParam<'w>(ResMut<'w, MyResource>);
/// ```
///
/// # Generic `SystemParam`s
///
/// When using the derive macro, you may see an error in the form of:
Expand Down

0 comments on commit c48b67f

Please sign in to comment.