Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

They are differently powerful. Rust's macros can let you extend the syntax and do context-free code generation, where as C++ can let you to type-directed code generation. You can do the latter in Rust using trait dispatch, but it's more awkward and less expressive than what C++ has.


It's not a panacea, but enum_dispatch seems to help a lot: https://docs.rs/enum_dispatch/0.3.5/enum_dispatch/




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: