-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Default piping via system return type #23666
Copy link
Copy link
Open
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesA "normal" level of difficulty; suitable for simple features or challenging fixesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!X-ContentiousThere are nontrivial implications that should be thought throughThere are nontrivial implications that should be thought through
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesA "normal" level of difficulty; suitable for simple features or challenging fixesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!X-ContentiousThere are nontrivial implications that should be thought throughThere are nontrivial implications that should be thought through
Type
Projects
Status
Needs SME Triage
What problem does this solve or what need does it fill?
Plenty of time I end up using
let Ok(...) else { return; }and such for early returning systems where I just want no-op without the required state I want. This isn't too bad but it bloats the code/makes it harder to read, which is where the?operator comes in handy. And then we can pipe toignore. However I think we might be able to go slightly further than this in terms of ease of use.What solution would you like?
Define 'default pipes' for the return type of a system. For example if I define a system like:
This would be the equivalent of:
What alternative(s) have you considered?
Just use the normal piping when we add the system to the world. Or maybe implement a default response for a BevyError? I'm not sure. It might be nice to be able to specify different responses based on the error we returned, e.g. not having this resource is fine, but if the entity doesn't have this component thats an invariant.