-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
More flexible SystemInput #21917
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?
More flexible SystemInput #21917
Conversation
chescock
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.
Note that #21916 and cBournhonesque#4 are alternative approaches to the same goal. I'm approving because this is a solid implementation of this approach, but I personally prefer #21916 because the change is smaller, and because associated types are less likely to cause type inference failures.
For example, world.run_system_cached_with(|_: StaticSystemInput<In<usize>>| {}, 0) would fail with "type annotations needed" under this PR, since I can be either In<usize> or StaticSystemInput<In<usize>>, while under #21916 it would unambiguously be In<usize>.
I don't know of any realistic use cases that would run into that problem, though. The only reason to use StaticSystemInput is if you're generic in the input type, like pipe, and in that case the types will all be written out anyway.
Valid! I still think I like this approach since it's a bit more symmetrical and doesn't add a new associated type, but I agree there could be problems with inference. I don't think there will be much more than present though, since IntoResult already leads to some ambiguities (like with |
284e441 to
826d1c0
Compare
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.
As long as we can't prove further type inference issues in general usecases, I'd be fine with this actually. Looks good besides the one thing.
|
Note for final review: compare with #21916 as an alternative. They're pretty similar but have a few differences with type inference and such |
Objective
Allow functions accepting
StaticSystemInputas input to be used as systems accepting the inner type.Solution
Testing
input.rsShowcase
Click to view showcase