Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a
RunSystem
extension trait to allow for immediate execution of systems on aWorld
for debugging and/or testing purposes.Objective
Fixes #6184
Initially, I made this CL as
ApplyCommands
. After a discussion with @cart , we decided a more generic implementation would be better to support all systems. This is the new revised CL. Sorry for the long delay! 😅This CL allows users to do this:
Solution
This is implemented as a trait extension and not included in any preludes to ensure it's being used consciously.
Internally, it just initializes and runs a systems, and applies any deferred parameters all "in place".
The trait has 2 functions (one of which calls the other by default):
run_system_with
is the general implementation, which allows user to pass system input parametersrun_system
is the ergonomic wrapper for systems with no input parameter (to avoid having the user pass()
as input).Additionally, this trait is also implemented for(Removed based on feedback)&mut App
. I added this mainly for ergonomics (app.run_system
vs.app.world.run_system
).