3 ms·
Back in the days before associated types you could implement `Deref` multiple times for the same type. That was fun.
by Thiez 6y ago
Back in the days before associated types you could implement `Deref` multiple times for the same type. That was fun.
- ivanbakel 6y agoYou can still do similarly hellish impls with `Index` - especially if you mix `Deref` into it. IIRC, the compiler will perform automatic recursive derefs when you try to use the indexing operator `[]`, until it finds a deref target which matches the index you're using. I doubt anything relies on that search behaviour outside of the compiler code itself. I imagine abuse of specialisation could also increase the confusion, if you were so inclined.