4 ms·
This isn't rocket science once you have sum types. enum Event<T> { System(SystemEvent), User(T), }
by Nullabillity 2y ago
This isn't rocket science once you have sum types.
enum Event<T> {
System(SystemEvent),
User(T),
}
- account42 2y agoUsing Rusts' retarded enum keyword for your example doesn't exactly make your point understandable, especially when talking in the context of actual enumerations. Anyway, the point of what gp describes is to do this in a single integer without overhead so a naive sum type is not the solution.
- Nullabillity 2y ago> Using Rusts' retarded enum keyword for your example doesn't exactly make your point understandable, especially when talking in the context of actual enumerations. data Event = System SystemEvent | User a > Anyway, the point of what gp describes is to do this in a single integer without overhead so a naive sum type is not the solution. Virtually all event systems end up carrying auxilary event data of some form, so sum types are what you want regardless.
- bluGill 2y agoAt least in C++ a template needs to be known at compile time, but I want to build my event loop and latter add in more values that should be handled without rebuilding it.
- Nullabillity 2y agoYou could make your `T` type as dynamic as you want it to be.