Skip to content

Commit 621cd23

Browse files
thebluefishmockersf
authored andcommitted
Fix EntityCommands::despawn docs (#13774)
# Objective The `EntityCommands::despawn` method was previously changed from panicking behavior to a warning, but the docs continue to state that it panics. ## Solution - Removed panic section, copied warning blurb from `World::despawn` - Adds a similar warning blurb to `DespawnRecursiveExt::despawn_recursive` and `DespawnRecursiveExt::despawn_descendants`
1 parent 7ae3c94 commit 621cd23

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,7 @@ impl EntityCommands<'_> {
10171017
}
10181018

10191019
/// Despawns the entity.
1020+
/// This will emit a warning if the entity does not exist.
10201021
///
10211022
/// See [`World::despawn`] for more details.
10221023
///
@@ -1025,10 +1026,6 @@ impl EntityCommands<'_> {
10251026
/// This won't clean up external references to the entity (such as parent-child relationships
10261027
/// if you're using `bevy_hierarchy`), which may leave the world in an invalid state.
10271028
///
1028-
/// # Panics
1029-
///
1030-
/// The command will panic when applied if the associated entity does not exist.
1031-
///
10321029
/// # Example
10331030
///
10341031
/// ```

crates/bevy_hierarchy/src/hierarchy.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ pub trait DespawnRecursiveExt {
9191

9292
impl DespawnRecursiveExt for EntityCommands<'_> {
9393
/// Despawns the provided entity and its children.
94+
/// This will emit warnings for any entity that does not exist.
9495
fn despawn_recursive(mut self) {
9596
let entity = self.id();
9697
self.commands().add(DespawnRecursive { entity });
@@ -105,6 +106,7 @@ impl DespawnRecursiveExt for EntityCommands<'_> {
105106

106107
impl<'w> DespawnRecursiveExt for EntityWorldMut<'w> {
107108
/// Despawns the provided entity and its children.
109+
/// This will emit warnings for any entity that does not exist.
108110
fn despawn_recursive(self) {
109111
let entity = self.id();
110112

0 commit comments

Comments
 (0)