3 ms·
Yes, but to me that's no different to saying "we don't need structs, we can do everything with `[u8; N]` and casts". Yes, that's true, but it's not type safe,
by Ericson2314 3y ago
Yes, but to me that's no different to saying "we don't need structs, we can do everything with `[u8; N]` and casts".
Yes, that's true, but it's not type safe, and I don't really want to program that way.
- johncolanduoni 3y agoHow is it not just as typesafe? Rust will enforce the same typing constraints on the arguments to qsort either way. You're making attestations about how the C code behaves that the Rust compiler cannot type-check for you, but both methods have that fundamental issue.
- Ericson2314 3y agoI won't be able to explain this succinctly. Sorry to be an asshole, but you are in Plato's cave of only having monomorphized types. The point of erased types is to be able to put in the language invariants that hitherto are only in our heads, but unless you have a typed-based mental model for what makes vtables/dictionaries safe (say, based on experience in other languages) you won't have ideas you can't write down, and thus you won't know what is missing. I wish there was a good blog-sized resource I could point you to that did explain it instead, but I don't know of any off-hand. I guess, try to wrote `dyn Trait` things (like a heterogenous collection) without `dyn Trait`, and then when it doesn't work without unsafe Rust, you will see what I mean.