Skip to content

Commit 35b8001

Browse files
committed
cleanup
1 parent 5ec12b1 commit 35b8001

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

subtyping.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ interactions with other features.)
4848
Some important variances:
4949

5050
* `&` is variant (as is `*const` by metaphor)
51-
* `&mut` is invariant (as is `*mut` by metaphor)
51+
* `&mut` is invariant
5252
* `Fn(T) -> U` is invariant with respect to `T`, but variant with respect to `U`
5353
* `Box`, `Vec`, and all other collections are variant
5454
* `UnsafeCell`, `Cell`, `RefCell`, `Mutex` and all "interior mutability"
55-
types are invariant
55+
types are invariant (as is `*mut` by metaphor)
5656

5757
To understand why these variances are correct and desirable, we will consider several
5858
examples. We have already covered why `&` should be variant when introducing subtyping:
@@ -158,7 +158,7 @@ in its place. Therefore functions *are* variant over their return type.
158158

159159
`*const` has the exact same semantics as `&`, so variance follows. `*mut` on the
160160
other hand can dereference to an &mut whether shared or not, so it is marked
161-
as invariant in analogy to cells.
161+
as invariant just like cells.
162162

163163
This is all well and good for the types the standard library provides, but
164164
how is variance determined for type that *you* define? A struct, informally

0 commit comments

Comments
 (0)