- Published on
Investigation · Part 4 of 10 · Types under the hood
Shape Without Behavior: Two Structs With the Same Fields
A Point and a Vector with the same two fields: TypeScript accepts one for the other, Rust refuses, and on this build the bytes and the instructions are identical, to the point that the optimized build keeps one function body under both names. The difference is a rule about names, and the name leaves no trace in the program.