More safely support untyped Observer
events
#17509
Labels
A-ECS
Entities, components, systems, and events
C-Feature
A new feature, making something new possible
D-Modest
A "normal" level of difficulty; suitable for simple features or challenging fixes
D-Unsafe
Touches with unsafe code in some way
S-Ready-For-Implementation
This issue is ready for an implementation PR. Go for it!
What problem does this solve or what need does it fill?
We don't currently support specifying an untyped event as the event type in an
Observer
Trigger
. Our "support" for it currently involves specifying some rust type as the event type and providing aTrigger::event_ptr
function which returns aPtr
, also not providing a version that returnsPtrMut
.Doing it this way can cause accidental UB on the user side very easily if they don't specify a type compatible with all of the event types.
What solution would you like?
We should directly support specifying untyped events as the event type in the
Trigger
like so:And then we would have a type function that maps
UntypedEvent
into aPtr
forTrigger::event()
and aPtrMut
forTrigger::event_mut()
.Additional context
Originally attempted in #14674 but that PR languished due to a too large of a scope.
The text was updated successfully, but these errors were encountered: