Here is a typical programmer’s error:
a numerical argument could stand for a width or a height. Both are integers, but it’s easy to pass invert the arguments (pass them in the wrong order). Then chaos ensues.
To guard against this a notion of a lightweight type would
be like a C typedef, but the compiler would issue a warning or even error if a width were passed to parameter expecting height, unless an explicit cast were done. Multiplying a width by a height yields an ordinary int of course, but this could be converted to an “area” type (for example).
This looks like a zero-cost abstraction to me, and would help protect against programming errors.
My knowledge of Rust is minimal, so I havent had time to check if this exists.
I think Ada has it, but I’m not sure.