Inherent associated types have been proposed for a very long time (7+ years). There is currently tracking issue #8995 for this, but nothing is listed as blocking. As far as I'm aware, this has never been implemented, but I also don't believe there should be anything major to hash out, given that associated consts are very much a thing (presumably some code could be shared?).
The reason I ask is because I recently wrote this code:
…which is terrible to read. Admittedly, I have the component module in scope to avoid bringing in a ton of structs, but even without that it's still a bit wild. Consider the alternative if inherent associated types were a thing:
Now the only repetition is for the enum → struct mapping, which is far better than before. The hierarchy is still clear, while repetition is minimal. I'd naturally prefer enum variant types as well, but that RFC hasn't even been merged yet.
So while I suppose it's a bit selfish, that's also the name of the game with most proposals What can be done to help push this forward?
while we may run into lazy normalization problems quickly, it should be totally fine to add associated types to inherent impls behind a feature gate. Considering that we already have most of the logic for trait impls, I don't see any inherent (heh) problems with this.
Also, would it be feasible to add a few special cases and start stabilizing them, even if the broader case is still blocked on lazy normalization?
By special cases, I'm thinking "Only types defined in child crates are allowed, and maybe non-generic types in the current crate". That way you don't risk running into cycle errors.
Definitely. If we can come up with a sane subset, we should stabilize it. If not, we may still stabilize it and just have really weird errors in the cases where lazy normalization is needed.
I don't think I'll have the capacity to implement this in the next few months, but I'd be happy to mentor it.