-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Support StaticSystemInput in more places
#21916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…erlying input type.
|
Would this work instead? |
Yeah, that would make We'd need to make the same change in a lot of places to make it work seamlessly everywhere, though, including |
|
I do think the approach of changing the call sites is better, but I won't block on this. I think this is a useful change! |
ItsDoot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, only thing I'd add is a test for a tuple of StaticSystemInputs and one for a mixed tuple of StaticSystemInput + a normal one.
|
I haven't done a full review yet, but if we go with this approach I'd like to bikeshed |
Yeah, if anyone has a good name, I'd be happy to update it! I usually use For a more brute-force approach, we could do something like Mostly I'm hoping that nobody needs to interact with this type very often, and that the doc comment mentioning
I added one test with a tuple of two |
Objective
Let functions that take
StaticSystemInput<I>be used in APIs that requireIntoSystem<I, O, M>.Higher-order systems that are generic in their input type need to wrap their input in
StaticSystemInput. Unfortunately, that means they are not usable withWorld::run_system_cachedorSchedule::add_systems, since those requireIn = ()and notIn = StaticSystemInput<()>.Solution
Add an associated type
SystemInput::Underlyingthat is equal toSelf(up to lifetimes) for all input types other thanStaticSystemInput<I>, and equal toI::UnderlyingforStaticSystemInput<I>. Use that associated type for<FunctionSystem as System>::In.That means a function taking
StaticSystemInput<()>will be turned into a system withIn = ()instead ofIn = StaticSystemInput<()>, making it usable forWorld::run_system_cachedandSchedule::add_systems.Testing
Updated the doc example of a safe
PipeSystemto call the resulting system withWorld::run_system_cachedinstead of needing to callSystem::runexplicitly.Added unit tests passing a function taking
StaticSystemInput<()>toWorld::run_system_cachedandSchedule::add_systems.