Generics: Stop Using void Pointers for Generic Code
C has several common ways to write generic code:
void *plus size and callbacks- macros that generate code for different types
- duplicated functions for different concrete types
All of them work, but each has a cost. void * loses type information, macros are harder to debug, and duplicated functions drift.
Rust generics solve the same problem: one piece of code can work for multiple types while keeping type checking.
Read More