Skip to content

Commit

Permalink
Replace some use of variant with covariant (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
chubei authored Nov 8, 2021
1 parent 358e6a6 commit c6b4bf8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/arc-mutex/arc-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ all the details on variance and drop check.
To fix the first problem, we can use `NonNull<T>`. Note that `NonNull<T>` is a
wrapper around a raw pointer that declares that:

* We are variant over `T`
* We are covariant over `T`
* Our pointer is never null

To fix the second problem, we can include a `PhantomData` marker containing an
Expand Down
2 changes: 1 addition & 1 deletion src/phantom-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct Iter<'a, T: 'a> {
}
```

and that's it. The lifetime will be bounded, and your iterator will be variant
and that's it. The lifetime will be bounded, and your iterator will be covariant
over `'a` and `T`. Everything Just Works.

Another important example is Vec, which is (approximately) defined as follows:
Expand Down
2 changes: 1 addition & 1 deletion src/subtyping.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ struct MyType<'a, 'b, A: 'a, B: 'b, C, D, E, F, G, H, In, Out, Mixed> {
f: Vec<F>, // covariant over F
g: Cell<G>, // invariant over G

h1: H, // would also be variant over H except...
h1: H, // would also be covariant over H except...
h2: Cell<H>, // invariant over H, because invariance wins all conflicts

i: fn(In) -> Out, // contravariant over In, covariant over Out
Expand Down

0 comments on commit c6b4bf8

Please sign in to comment.