Hacker News new | past | comments | ask | show | jobs | submit login

Back in the days before associated types you could implement `Deref` multiple times for the same type. That was fun.



You 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.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: