I understand why the orphan rules are in place, but in theory, couldn't trait aliases be revised to also allow implementations on them to allow users to, for example, easily derive Serialize
and Deserialize
on external types?
This may sound bad (and understandably so, since newtypes are always a fine alternative), but let's see:
trait SerializeExt = Serialize;
impl SerializeExt for OnceCell { ... }
You would have to import SerializeExt
directly to have Serialize
for OnceCell
, like any other trait, but would also function like Serialize
(so any function taking a type of Serialize
can also take SerializeExt
). Isn't the entire issue that the orphan rules solve completely done away by this? That is, external crates implementing traits for external types and causing dependency hell.
I could be very wrong though so please tear this whole thing apart I'm posting for exactly that
For starters, I could see that this kind of goes against the idea of this being an "alias", considering type aliases can't be implemented on (though this is something I've always dreamed for, even if it's unlikely to ever happen!)