Named and scoped trait implementations as a solution to orphan rules [ok, it wont' work]

We initially had scoped impls in Rust. We removed them because of what we called “the hashtable problem”. This e-mail of mine from 2011 kind of goes into some of the details, I think. We called it the hashtable problem because – imagine you had a hashtable with keys to type K that is built up using one impl of Hash, but then you pass that hashtable to another module, where a distinct Hash impl is in scope. It’s going to be pandemonium. What that e-mail proposed was to solve this by making the impl “part of the type”, in a sense. At the end of the day it seemed like a lot of complexity and we opted against it – but there are real costs. I’m not sure of the best fix here.

2 Likes