Skip to content

Replace some use of variant with covariant #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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