Skip to content

Commit d9abcb6

Browse files
authored
Fix definition of contravariance
Also clarify what F *is*.
1 parent 13e3745 commit d9abcb6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/subtyping.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ For instance `Vec` is a type constructor that takes a `T` and returns a
6464
`Vec<T>`. `&` and `&mut` are type constructors that take two inputs: a
6565
lifetime, and a type to point to.
6666

67-
A type constructor's *variance* is how the subtyping of its inputs affects the
67+
A type constructor F's *variance* is how the subtyping of its inputs affects the
6868
subtyping of its outputs. There are three kinds of variance in Rust:
6969

7070
* F is *covariant* over `T` if `T` being a subtype of `U` implies
7171
`F<T>` is a subtype of `F<U>` (subtyping "passes through")
7272
* F is *contravariant* over `T` if `T` being a subtype of `U` implies
73-
`F<U>` is a subtype of `F<U>` (subtyping is "inverted")
73+
`F<U>` is a subtype of `F<T>` (subtyping is "inverted")
7474
* F is *invariant* over `T` otherwise (no subtyping relation can be derived)
7575

7676
It should be noted that covariance is *far* more common and important than

0 commit comments

Comments
 (0)