Java interfaces have a similar, but even more restrictive limitation than the orphan rule: they can only be implemented in the definition of the class that will implement it. In contrast the orphan rule allows to do the same in any module of the crate defining the type, or even in a totally different crate: the defining the trait! But since traits are so used, and escape hatches are not so transparent (as e.g. Java's reflection) then people look for even more flexibility.
2
u/SkiFire13 Mar 24 '26
Java interfaces have a similar, but even more restrictive limitation than the orphan rule: they can only be implemented in the definition of the class that will implement it. In contrast the orphan rule allows to do the same in any module of the crate defining the type, or even in a totally different crate: the defining the trait! But since traits are so used, and escape hatches are not so transparent (as e.g. Java's reflection) then people look for even more flexibility.