File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
3
3
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4
- refs/heads/try: 5ec12b154bcc839f9a903f238791b6010a61418b
4
+ refs/heads/try: 35b8001f684399992978c60fcb3d51232b3ca85d
5
5
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
6
6
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
7
7
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Original file line number Diff line number Diff line change @@ -48,11 +48,11 @@ interactions with other features.)
48
48
Some important variances:
49
49
50
50
* ` & ` is variant (as is ` *const ` by metaphor)
51
- * ` &mut ` is invariant (as is ` *mut ` by metaphor)
51
+ * ` &mut ` is invariant
52
52
* ` Fn(T) -> U ` is invariant with respect to ` T ` , but variant with respect to ` U `
53
53
* ` Box ` , ` Vec ` , and all other collections are variant
54
54
* ` UnsafeCell ` , ` Cell ` , ` RefCell ` , ` Mutex ` and all "interior mutability"
55
- types are invariant
55
+ types are invariant (as is ` *mut ` by metaphor)
56
56
57
57
To understand why these variances are correct and desirable, we will consider several
58
58
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.
158
158
159
159
` *const ` has the exact same semantics as ` & ` , so variance follows. ` *mut ` on the
160
160
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.
162
162
163
163
This is all well and good for the types the standard library provides, but
164
164
how is variance determined for type that * you* define? A struct, informally
You can’t perform that action at this time.
0 commit comments