Skip to content
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/change_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub(crate) struct Ticks<'a> {
pub(crate) change_tick: u32,
}

/// Unique mutable borrow of a resource.
/// Unique mutable borrow of a [`Resource`].
///
/// See the [`World`](crate::world::World) documentation to see the usage of a resource.
///
Expand Down
11 changes: 10 additions & 1 deletion crates/bevy_ecs/src/system/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,18 @@ pub struct ParamSetState<T: for<'w, 's> SystemParamFetch<'w, 's>>(T);

impl_param_set!();

/// A type that can be inserted into a [`World`](crate::world::World) as a singleton.
///
/// Resources are commonly used to store global collections (like assets or events),
/// or unique global information (such as the current level or state of the app).
///
/// You can access resource data in systems using the [`Res`] and [`ResMut`] system parameters.
///
/// Only one resource of each type can exist at any given time.
/// Inserting a duplicate resource will overwrite the existing resource.
Comment on lines +225 to +233
Copy link
Contributor

@Nilirad Nilirad Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second paragraph seems too specific to me: mentioning use cases and applications is something more suitable to the book imo. API docs are best suited to describe the item itself.

This description also does not illustrate how to insert a resource to the world (i.e. World::init_resource or World::insert_resource). I would avoid mentioning the App methods though, as they are not defined from the bevy_ecs perspective.

Comment on lines +225 to +233
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inserting a duplicate resource will overwrite the existing resource.

This is something that is up to the insert_resource method and not to the type that implements Resource. Also, if the concept of “inserting” is broadened to init_resource, that statement becomes incorrect.

pub trait Resource: Send + Sync + 'static {}

/// Shared borrow of a resource.
/// Shared borrow of a [`Resource`].
///
/// See the [`World`] documentation to see the usage of a resource.
///
Expand Down