Skip to content

Commit 2c00df2

Browse files
Docs clarity for init_resource
1 parent 9ee981d commit 2c00df2

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

crates/bevy_app/src/app.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,13 @@ impl App {
673673
self
674674
}
675675

676-
/// Initialize a resource with default values by adding it to the [`World`]
676+
/// Initialize a resource with standard starting values by adding it to the [`World`]
677677
///
678678
/// If the resource already exists, nothing happens.
679679
///
680-
/// The resource must implement either the `Default` or [`FromWorld`] trait.
680+
/// The resource must implement the [`FromWorld`] trait.
681+
/// If the `Default` trait is implemented, the `FromWorld` trait will use
682+
/// the `Default::default` method to initialize the resource.
681683
///
682684
/// ## Example
683685
/// ```
@@ -703,11 +705,11 @@ impl App {
703705
self
704706
}
705707

706-
/// Initialize a non-send resource with default values by adding it to the [`World`]
708+
/// Initialize a non-send resource with standard starting values by adding it to the [`World`]
707709
///
708-
/// If the resource already exists, nothing happens.
709-
///
710-
/// The resource must implement either the `Default` or [`FromWorld`] trait.
710+
/// The resource must implement the [`FromWorld`] trait.
711+
/// If the `Default` trait is implemented, the `FromWorld` trait will use
712+
/// the `Default::default` method to initialize the resource.
711713
pub fn init_non_send_resource<R: 'static + FromWorld>(&mut self) -> &mut Self {
712714
self.world.init_non_send_resource::<R>();
713715
self

crates/bevy_ecs/src/system/commands/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl<'w, 's> Commands<'w, 's> {
261261
self.queue.push(InsertOrSpawnBatch { bundles_iter });
262262
}
263263

264-
/// Inserts a resource with default values to the [`World`].
264+
/// Inserts a resource with standard starting values to the [`World`].
265265
///
266266
/// If the resource already exists, nothing happens.
267267
///

crates/bevy_ecs/src/world/mod.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -592,12 +592,13 @@ impl World {
592592
}
593593
}
594594

595-
/// Inserts a new resource with default values.
595+
/// Inserts a new resource with standard starting values.
596596
///
597597
/// If the resource already exists, nothing happens.
598598
///
599-
/// Uses the [`FromWorld`] trait to determine values,
600-
/// which has a blanket impl for all `R: Default`.
599+
/// The value given by the [`FromWorld::from_world`] method will be used.
600+
/// Note that any resource with the `Default` trait automatically implements `FromWorld`,
601+
/// and those default values will be here instead.
601602
#[inline]
602603
pub fn init_resource<R: Resource + FromWorld>(&mut self) {
603604
// PERF: We could avoid double hashing here, since the `from_resources` call is guaranteed
@@ -621,12 +622,13 @@ impl World {
621622
unsafe { self.insert_resource_with_id(component_id, value) };
622623
}
623624

624-
/// Inserts a new non-send resource with default values.
625+
/// Inserts a new non-send resource with standard starting values.
625626
///
626627
/// If the resource already exists, nothing happens.
627628
///
628-
/// Uses the [`FromWorld`] trait to determine values,
629-
/// which has a blanket impl for all `R: Default`.
629+
/// The value given by the [`FromWorld::from_world`] method will be used.
630+
/// Note that any resource with the `Default` trait automatically implements `FromWorld`,
631+
/// and those default values will be here instead.
630632
#[inline]
631633
pub fn init_non_send_resource<R: 'static + FromWorld>(&mut self) {
632634
// PERF: We could avoid double hashing here, since the `from_resources` call is guaranteed

0 commit comments

Comments
 (0)