From 74502b368c2fab5ba426d7232fc4faacd9c3d797 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Wed, 8 Jan 2025 02:02:47 -0800 Subject: [PATCH] Mutable query --- src/main.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index a0c021b..e08f03b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,9 +24,19 @@ fn greet_people(query: Query<&Name, With>) { } } +fn update_people(mut query: Query<&mut Name, With>) { + + for mut name in &mut query { + if name.0 == "Orlando Tampa" { + name.0 = "Carlos Satanick".to_string(); + } + break; + } +} + fn main() { App::new() .add_systems(Startup, add_people) - .add_systems(Update, (gamarjoba, greet_people)) + .add_systems(Update, (gamarjoba, (update_people, greet_people).chain())) .run(); }