3 ms·
How does it handle an implementation of a trait being in scope in one compilation unit and out of scope in another? That's the wicked problem.
by direwolf20 9mo ago
How does it handle an implementation of a trait being in scope in one compilation unit and out of scope in another? That's the wicked problem.
- amluto 9mo agoIt’s impossible (?) due to the “coherence” rule. A type A can implement a trait B in two places: the crate where A is defined or the crate where B is defined. So if you can see A and B, you know definitely whether A implements B. The actual rule is more complex due to generics: https://github.com/rust-lang/rfcs/blob/master/text/2451-re-rebalancing-coherence.md https://github.com/rust-lang/rfcs/blob/master/text/2451-re-r... and that document doesn’t actually seem to think that this particular property is critical.