From 70902413b2a79c352813c945493ab1bcc5d94fa9 Mon Sep 17 00:00:00 2001 From: krunchington Date: Mon, 30 Jun 2025 16:01:44 -0700 Subject: [PATCH] Update log_layers_ecs example for children macro (#18293) # Objective Contributes to #18238 Updates the `log_layers_ecs`, example to use the `children!` macro. Note that I did not use a macro, nor `Children::spawn` for the outer layer. Since the `EventReader` is borrowed mutably, any `.map` I did on `events.read()` was going to have the reference outlive the function body. I believe this scope of change is correct for the PR. ## Solution Updates examples to use the Improved Spawning API merged in https://github.com/bevyengine/bevy/pull/17521 ## Testing - Did you test these changes? If so, how? - Opened the examples before and after and verified the same behavior was observed. I did this on Ubuntu 24.04.2 LTS using `--features wayland`. - Are there any parts that need more testing? - Other OS's and features can't hurt, but this is such a small change it shouldn't be a problem. - How can other people (reviewers) test your changes? Is there anything specific they need to know? - Run the examples yourself with and without these changes. - If relevant, what platforms did you test these changes on, and are there any important ones you can't test? - see above --- ## Showcase n/a ## Migration Guide n/a Co-authored-by: Alice Cecile --- examples/app/log_layers_ecs.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/app/log_layers_ecs.rs b/examples/app/log_layers_ecs.rs index 55e57081ff..bcf5e5571e 100644 --- a/examples/app/log_layers_ecs.rs +++ b/examples/app/log_layers_ecs.rs @@ -150,13 +150,16 @@ fn print_logs( commands.entity(root_entity).with_children(|child| { for event in events.read() { - child.spawn(Text::default()).with_children(|child| { - child.spawn(( - TextSpan::new(format!("{:5} ", event.level)), - TextColor(level_color(&event.level)), - )); - child.spawn(TextSpan::new(&event.message)); - }); + child.spawn(( + Text::default(), + children![ + ( + TextSpan::new(format!("{:5} ", event.level)), + TextColor(level_color(&event.level)), + ), + TextSpan::new(&event.message), + ], + )); } }); }