Re:The Resurgence of C Programming
by steveklabnik on Tuesday December 27, 2016 @03:21PM
(#13265896)
We do not yet have type-level integers; they are highly desired by a subset of Rust programmers, and there is an open RFC.
And for programmers who are desperate to use type-level integers, there exists typenum, which is an encoding of integers in Rust's type system. They can also be used to parameterize array length (the generic-array crate), one of the main uses of such a beast.
That said, I am also looking forward to true type-level integers; they're needed for the truly proper translation of fixed size arrays in the Fuchsia IDL (fidl).
Re:The Resurgence of C Programming
by Manishearth on Wednesday December 28, 2016 @02:02PM
(#13272729)
Rust has specialization (newish feature). Value generics aren't there, but lots of folks want them, so we'll see.
C++ templates are unique in that they let you do a lot more than that; for example, you can have a different implementation for one specific type. std::vector<bool> is implemented differently from any other std::vector<K>. You can also have templates over values, not just types; so you could define some T such that T<5> differs from T<6> in some way.
I don't know rust; does it allow stuff like this?