Skip to content

Commit 8fec610

Browse files
authored
Merge pull request #701 from spastorino/show-display
Show -> Display
2 parents d0d8fbe + 3b6364d commit 8fec610

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

book/src/clauses/coherence.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
This document was previously prepared for the initial design of coherence rules in Chalk. It was copy-pasted here on 2020-10-06, but has not been vetted for accuracy of the current implementation or edited for clarity.
44

55
## Coherence
6-
> The idea of trait coherence is that, given a trait and some set of types for its type parameters, there should be exactly one impl that applies. So if we think of the trait `Show`, we want to guarantee that if we have a trait reference like `MyType : Show`, we can uniquely identify a particular impl.
6+
> The idea of trait coherence is that, given a trait and some set of types for its type parameters, there should be exactly one impl that applies. So if we think of the trait `Display`, we want to guarantee that if we have a trait reference like `MyType : Display`, we can uniquely identify a particular impl.
77
>
8-
> The role of the orphan rules in particular is basically to prevent you from implementing external traits for external types. So continuing our simple example of `Show`, if you are defining your own library, you could not implement `Show` for `Vec<T>`, because both `Show` and `Vec` are defined in the standard library. But you can implement `Show` for `MyType`, because you defined `MyType`. However, if you define your own trait `MyTrait`, then you can implement `MyTrait` for any type you like, including external types like `Vec<T>`. To this end, the orphan rule intuitively says “either the trait must be local or the self-type must be local”.
8+
> The role of the orphan rules in particular is basically to prevent you from implementing external traits for external types. So continuing our simple example of `Display`, if you are defining your own library, you could not implement `Display` for `Vec<T>`, because both `Display` and `Vec` are defined in the standard library. But you can implement `Display` for `MyType`, because you defined `MyType`. However, if you define your own trait `MyTrait`, then you can implement `MyTrait` for any type you like, including external types like `Vec<T>`. To this end, the orphan rule intuitively says “either the trait must be local or the self-type must be local”.
99
>
1010
> -- [Little Orphan Impls](https://smallcultfollowing.com/babysteps/blog/2015/01/14/little-orphan-impls/) by Niko Matsakis
1111

0 commit comments

Comments
 (0)