3 ms·
Why did a Rust defect become such a diatribe on C++ ? As far as I am aware, using a typedef/using type does not slow down zero-based initialisation of primitive
by lenkite 5y ago
Why did a Rust defect become such a diatribe on C++ ? As far as I am aware, using a typedef/using type does not slow down zero-based initialisation of primitive types in C++. (last time I checked a few years ago - will apologise if this has changed).
- yyyk 5y agoSorry, got bit a bit too much by C++ templates and a few other things. Rust views itself as a successor language, and I wouldn't like it to make the same mistakes.
- tialaramex 5y agoRust wrapper types aren't like C++ typedef. If you just want an alias for the u8 type in Rust, you get the exact same performance: type Tiny = u8; The compiler knows a "Tiny" is just a u8 anyway and exactly the same code is produced. The wrapper type is a distinct type, which is why you'd want one because it can have different properties from whatever it's wrapping.
- jcranberry 5y agoThe newtype is analogous to what I've heard called a "strong typedef" in c++ lingo. Using/typedef declarations in c++ only introduce a new name, not a new type.