5 ms·
Oh yeah, C++ templates work more on the token level than Rust generics. Didn't know that type_traits was meant for that. Indeed Rust proc macros, or Rust macro
by est31 6y ago
Oh yeah, C++ templates work more on the token level than Rust generics. Didn't know that type_traits was meant for that.
Indeed Rust proc macros, or Rust macros in general, are a better analog to C++ templates than Rust generics. They aren't quite the same, as during evaluation time C++ can do a bit more, and apparently type_traits is an example of what C++ can do statically. Rust's model is different, it wants macro expansion to be done by the time it starts even resolving any non-macro paths, let alone type checking or anything.
That being said, you'll be able to emulate something like that once specialization lands (hopefully also included by min_specialization).