From 07da3b6de86399e23fc75307ecc750424dabbd3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Mockers?= Date: Sun, 4 Jul 2021 22:41:32 +0200 Subject: [PATCH] better doc --- crates/bevy_ecs/src/system/commands/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index 6b8c3b548ac9fa..a1f2b1a4e57cd1 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -155,6 +155,23 @@ impl<'a> Commands<'a> { } /// Run a one-off [`System`]. + /// + /// ``` + /// # use bevy_ecs::prelude::*; + /// # struct MyComponent; + /// + /// # fn my_system(_components: Query<&MyComponent>) {} + /// + /// # fn main_system(mut commands: Commands) { + /// // Can take a standard system function + /// commands.run_system(my_system); + /// // Can take a closure system + /// commands.run_system(|query: Query<&MyComponent>| { + /// println!("count: {}", query.iter().len()); + /// }); + /// # } + /// # main_system.system(); + /// ``` pub fn run_system(&mut self, system: impl IntoSystem<(), (), Params>) { self.queue.push(RunSystem { system: Box::new(system.system()),