3 ms·
That isn't always a benefit, though. When interfacing with a database schema that uses small integers for ids, I'm all the time defining types like `struct Cust
by couchand 6y ago
That isn't always a benefit, though. When interfacing with a database schema that uses small integers for ids, I'm all the time defining types like `struct CustomerId(u32)` and `struct InvoiceId(u32)`. It's incredibly valuable that the compiler will not let me mix up a customer and an invoice, even if both of them are 42.
- joshuamorton 6y agoAd hoc and structural polymorphism can coexist. You can define an object that contains a customerid and an invoiceid, and they won't get mixed.