Hacker News new | ask | show | jobs
by HarHarVeryFunny 1335 days ago
Of course the Rust features being used by that Event type are runtime polymorphism and type introspection, so another obvious C++ approach would be just to use a pointer to a virtual based class including the type, then:

switch (event->type) {

case EvKeyPressEvent:

  {

    auto kpe - dynamic_cast<KeyPressEvent*>(event)

    ...

  }

  break;

}