3 ms·
As far as i understand, Rust is strongly typed, has generics and no type erasure. I also suppose String is some kind of a primitive type. Could it be possible t
by lolive 8y ago
As far as i understand, Rust is strongly typed, has generics and no type erasure. I also suppose String is some kind of a primitive type. Could it be possible to make it parametrizable, so we can manipulate a String<FirstName> as a String, but the compiler will never confound it with (for example) String<LastName>.
- steveklabnik 8y agoString is a library type, not a primitive type. You could write your own string parameterized in this way, but it would be incompatible with the standard library String and so you’d need the same conversion steps.
- lolive 8y agoWhat would happen if the Rust core team decided to parametrize String? Would it work with legacy code? (that creates something like String<?> and consume String<?>).
- steveklabnik 8y agoIt cannot be done in a backwards compatible way with today’s language features.