-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Require #[derive(Event)]
on all Events
#7086
Conversation
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.
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. |
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 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
Resource
s andComponents
and haveEvent
types be more self-documenting.Although not susceptible to accidentally using a function instead of a value due to
Event
s only being initialized by their type, much of the same reasoning for removing the blanket impl onResource
also applies here.Solution
Remove the blanket impl for the
Event
trait. Add a derive macro for it.Changelog
Event
is 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.