Skip to content

Commit a30bf14

Browse files
committed
---
yaml --- r: 228994 b: refs/heads/try c: 35b8001 h: refs/heads/master v: v3
1 parent 058602b commit a30bf14

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 5ec12b154bcc839f9a903f238791b6010a61418b
4+
refs/heads/try: 35b8001f684399992978c60fcb3d51232b3ca85d
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/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)