Repository navigation
Require #[derive(Event)] on all Events - #7086
Conversation
james7132
left a comment
There was a problem hiding this comment.
Tentatively approving this on the same grounds as #[derive(Resource)]. This should provide solid ground for compile time optimization in the future for events (i.e. garbage collection policy).
Marking this as controversial as this definitely adds friction when integrating with third party crates.
4a6c1af to
32ead94
Compare
32ead94 to
b03c5a4
Compare
c8a6d2a to
e6f192d
Compare
103439b to
105f6c4
Compare
|
Closing as this does not improve the developer experience in isolation. |
|
I don't agree. Admittedly, it was only once, but this feature would have saved me an hour of debugging when I mistakenly used the wrong type in an |
|
@CatThingy can you consider re-opening this? Most people seem to think this PR is a good idea. |
|
Doesn't this need documentation changes? Migration instructions? |
Documentation changes I actually don't think are needed: the blog post will contain a blurb and the examples will all demonstrate the pattern. Migration guide is done: it's just adding a derive and newtyping when needed. People are used to this with components and resources already. |
cart
left a comment
There was a problem hiding this comment.
Looks good to me. Consistent with our other ECS apis / traits and paves the way for static event configuration (which we almost certainly want).
|
@CatThingy can you get this passing CI? Once that's done we'll finally merge this in :) |
Objective
Be consistent with
Resources andComponentsand haveEventtypes be more self-documenting.Although not susceptible to accidentally using a function instead of a value due to
Events only being initialized by their type, much of the same reasoning for removing the blanket impl onResourcealso applies here.Solution
Remove the blanket impl for the
Eventtrait. Add a derive macro for it.Changelog
Eventis no longer implemented for all applicable types. Add the#[derive(Event)]macro for events.Migration Guide
#[derive(Event)]macro for events. Third-party types used as events should be wrapped in a newtype.