Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
EventWriter<T>
are currently confusing to users: why does it matter if the underlying type is a resource?T
is never stored as a resource, instead,Events<T>
is inserted as a resource.Resource
, anyEvents<T>
will beSend + Sync + 'static
if and only ifT
is.Event
orResource
non-trivial, this coupling will be confusing and error-prone.Solution
Event: Send + Sync + 'static
trait, and use this in place ofResource
in the assorted event types.Event
so users do not need to manually implement or derive this trait (yet).Changelog
Events<T>
,EventWriter<T>
,EventReader<T>
and so on now require that the underlying type isEvent
, rather thanResource
. Both of these are trivial supertraits ofSend + Sync + 'static
with universal blanket implementations: this change is currently purely cosmetic.Context
This was first discussed in the context of the more controversial #2073.
You can see the confusion that this sort of conflation generates in #4680 (comment), where the changes made to the
Resource
trait echo through to our event types in surprising ways.Down the line, there's an argument to be made for forcing a derive macro on both
Resource
andEvent
, and supporting more configuration, but that's a conversation for another day.