Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Alice Cecile <[email protected]>
  • Loading branch information
B-Janson and alice-i-cecile committed Sep 13, 2021
1 parent 2fa50b2 commit cd63208
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Example | File | Description
`component_change_detection` | [`ecs/component_change_detection.rs`](./ecs/component_change_detection.rs) | Change detection on components
`event` | [`ecs/event.rs`](./ecs/event.rs) | Illustrates event creation, activation, and reception
`fixed_timestep` | [`ecs/fixed_timestep.rs`](./ecs/fixed_timestep.rs) | Shows how to create systems that run every fixed timestep, rather than every tick
`generic_system` | [`ecs/generic_system.rs`](./ecs/generic_system.rs) | Shows how to create generic systems
`generic_system` | [`ecs/generic_system.rs`](./ecs/generic_system.rs) | Shows how to create systems that can be reused with different types
`hierarchy` | [`ecs/hierarchy.rs`](./ecs/hierarchy.rs) | Creates a hierarchy of parents and children entities
`iter_combinations` | [`ecs/iter_combinations.rs`](./ecs/iter_combinations.rs) | Shows how to iterate over combinations of query results.
`parallel_query` | [`ecs/parallel_query.rs`](./ecs/parallel_query.rs) | Illustrates parallel queries with `ParallelIterator`
Expand Down
3 changes: 3 additions & 0 deletions examples/ecs/generic_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fn main() {
.add_system_set(SystemSet::on_update(AppState::MainMenu).with_system(transition_to_in_game))
// add the cleanup systems
.add_system_set(
// Pass in the types your system should operate on using the ::<T> (turbofish) syntax
SystemSet::on_exit(AppState::MainMenu).with_system(cleanup_system::<MenuClose>),
)
.add_system_set(
Expand Down Expand Up @@ -58,6 +59,8 @@ fn transition_to_in_game(mut state: ResMut<State<AppState>>, keyboard_input: Res
}
}

// Type arguments on functions come after the function name, but before ordinary arguments.
// Here, the `Component` trait is a trait bound on T, our generic type
fn cleanup_system<T: Component>(mut commands: Commands, query: Query<Entity, With<T>>) {
for e in query.iter() {
commands.entity(e).despawn_recursive();
Expand Down

0 comments on commit cd63208

Please sign in to comment.