Skip to content

Commit 07da3b6

Browse files
committed
better doc
1 parent 7bdc067 commit 07da3b6

File tree

1 file changed

+17
-0
lines changed
  • crates/bevy_ecs/src/system/commands

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,23 @@ impl<'a> Commands<'a> {
155155
}
156156

157157
/// Run a one-off [`System`].
158+
///
159+
/// ```
160+
/// # use bevy_ecs::prelude::*;
161+
/// # struct MyComponent;
162+
///
163+
/// # fn my_system(_components: Query<&MyComponent>) {}
164+
///
165+
/// # fn main_system(mut commands: Commands) {
166+
/// // Can take a standard system function
167+
/// commands.run_system(my_system);
168+
/// // Can take a closure system
169+
/// commands.run_system(|query: Query<&MyComponent>| {
170+
/// println!("count: {}", query.iter().len());
171+
/// });
172+
/// # }
173+
/// # main_system.system();
174+
/// ```
158175
pub fn run_system<Params>(&mut self, system: impl IntoSystem<(), (), Params>) {
159176
self.queue.push(RunSystem {
160177
system: Box::new(system.system()),

0 commit comments

Comments
 (0)