I’m pretty sure this has been discussed before, but I couldn’t find an existing RFC.
Let’s say have have a library
aa with a trait
A that is designed to be implemented by its users, and a library
bb with a type
B. These two libraries do not “know” about each other. They might be from different authors.
Now, I make project
cc where I want to both libraries and have
impl A for B. This is impossible, since the language requires trait implementations to be either in the same crate as the trait or in the same crate as the type. (Is that correct?)
The best I can do is go to the author of one of the libraries and ask them to have the
impl in their crate with an optional dependency on the other library. This requires a lot more coordination than I feel should be necessary, and becomes tedious if it needs to happen for every pair of unrelated libraries that someone happen to want to use together. Even when the author of all three projects is the same, it’s kinda awkward to have in a general purpose library this unrelated
I don’t really have a proposal here, but is possible to do better than this in current Rust? Or with a change to the language?