|
|
|
|
|
by logicchains
2330 days ago
|
|
>Java generics are crippled due to type erasure; Rust and Haskell don't have those limitations. Both Rusk and Haskell erase types at runtime. The difference is they don't rely on runtime reflection for anything, so it doesn't hurt them. |
|
In Rust, each instance of a generic function is compiled separately and customized as necessary to the specific type parameters. You can write "let t = T::new();" because the compiler will generate a call to the correct constructor for each instance of the generic code. In this sense, types are NOT erased.