File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,15 @@ be instantiable with the same set of types for the input type parameters. -->
174
174
r[ items.impl.trait.orphan-rule]
175
175
#### Orphan rules
176
176
177
+ r[ items.impl.trait.orphan-rule.rationale]
178
+ The orphan rules ensure that other peoples code can't break your code, and vice versa.
179
+ If an external crate implements an external trait for an external type, and your crate also
180
+ implements the same trait for the same type, the compiler wouldn't know which implementation
181
+ to use.\
182
+ The orphan rule prevents this by requiring that either the trait or some type in the
183
+ implementation is local to your crate, ensuring only one crate defines the implementation and
184
+ thereby maintaining coherence.
185
+
177
186
r[ items.impl.trait.orphan-rule.general]
178
187
Given ` impl<P1..=Pn> Trait<T1..=Tn> for T0 ` , an ` impl ` is valid only if at
179
188
least one of the following is true:
You can’t perform that action at this time.
0 commit comments