Fallible component lifecycle hooks
Open
A-ECS
C-Feature
S-Ready-For-Implementation
X-Uncontroversial
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
Currently, a [component lifecycle hook](https://docs.rs/bevy/latest/bevy/ecs/lifecycle/type.ComponentHook.html) only accepts a `fn(DeferredWorld<'_>, HookContext)`.
This means that you cannot propagate errors from inside a lifecyle hook.
## What solution would you like?
Make it so that lifecycle hooks can accept a `fn(DeferredWorld<'_>, HookContext) -> Result`, just like systems and observers.
This way a user can use `?` from inside lifecycle hooks too.
## What alternative(s) have you considered?
Litter your code with `.unwrap()` or `.expect(...)`.
Contributor guide
Assessment
This issue has not been assessed yet.