In Rust, the "orphan rules" forbid you from writing an impl where both the trait and the type are defined in a different crate.
According to Coherence and Orphan Rules in Rust:
The "orphan rules", very roughly speaking, forbid you from writing an
impl
where both the trait and the type are defined in a different crate. This is meant to:
Prevent "dependency hell" problems where multiple crates write conflicting
impl
s, so nobody can ever use both crates in the same program, and the crate authors don't even realize they've created this footgun until someone tries to combine them.Allow crates to add
impl
s for their traits and types without it being considered a breaking change. Without the orphan rules, no crate would ever be allowed to add animpl
in a minor or patch version because that would break any program that contained an overlappingimpl
.