Skip to content

Commit 780f658

Browse files
authored
Update ChildOf deprecation advice to match new layout (#18089)
#17905 replaced `ChildOf(entity)` with `ChildOf { parent: entity }`, but some deprecation advice was overlooked. Also corrected formatting in documentation. ## Testing Added a `set_parent` to a random example. Confirmed that the deprecation warning shows and the advice can be pasted in.
1 parent e43b28c commit 780f658

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

crates/bevy_ecs/src/hierarchy.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ use log::warn;
5252
/// # use bevy_ecs::prelude::*;
5353
/// # let mut world = World::new();
5454
/// let root = world.spawn_empty().id();
55-
/// let child1 = world.spawn(ChildOf {parent: root}).id();
56-
/// let child2 = world.spawn(ChildOf {parent: root}).id();
57-
/// let grandchild = world.spawn(ChildOf {parent: child1}).id();
55+
/// let child1 = world.spawn(ChildOf { parent: root }).id();
56+
/// let child2 = world.spawn(ChildOf { parent: root }).id();
57+
/// let grandchild = world.spawn(ChildOf { parent: child1 }).id();
5858
///
5959
/// assert_eq!(&**world.entity(root).get::<Children>().unwrap(), &[child1, child2]);
6060
/// assert_eq!(&**world.entity(child1).get::<Children>().unwrap(), &[grandchild]);
@@ -200,7 +200,10 @@ impl<'w> EntityWorldMut<'w> {
200200
}
201201

202202
/// Inserts the [`ChildOf`] component with the given `parent` entity, if it exists.
203-
#[deprecated(since = "0.16.0", note = "Use entity_mut.insert(ChildOf(entity))")]
203+
#[deprecated(
204+
since = "0.16.0",
205+
note = "Use entity_mut.insert(ChildOf { parent: entity })"
206+
)]
204207
pub fn set_parent(&mut self, parent: Entity) -> &mut Self {
205208
self.insert(ChildOf { parent });
206209
self
@@ -246,7 +249,10 @@ impl<'a> EntityCommands<'a> {
246249
}
247250

248251
/// Inserts the [`ChildOf`] component with the given `parent` entity, if it exists.
249-
#[deprecated(since = "0.16.0", note = "Use entity_commands.insert(ChildOf(entity))")]
252+
#[deprecated(
253+
since = "0.16.0",
254+
note = "Use entity_commands.insert(ChildOf { parent: entity })"
255+
)]
250256
pub fn set_parent(&mut self, parent: Entity) -> &mut Self {
251257
self.insert(ChildOf { parent });
252258
self

0 commit comments

Comments
 (0)