From c48b67fb41a4e0cf2c585158560d727665f3405d Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Thu, 29 Dec 2022 00:36:10 -0500 Subject: [PATCH] add docs for the new attributes --- crates/bevy_ecs/src/system/system_param.rs | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index 2fb33932783e4..6cd3dd6e8c947 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -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::*; @@ -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: