File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
branches/beta/src/doc/tarpl Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
23
23
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
24
24
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
25
25
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26
- refs/heads/beta: 5f6e0abe27aa6632f95492ad8864d8084c1bacef
26
+ refs/heads/beta: 99043dde9dd2d0507ad2e3cda65b9d3e9244f13f
27
27
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28
28
refs/heads/tmp: 938f5d7af401e2d8238522fed4a612943b6e77fd
29
29
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
Original file line number Diff line number Diff line change @@ -95,10 +95,9 @@ actually possible to communicate this at the type level by returning a
95
95
knowing that it's * statically impossible* for this value to be an ` Err ` , as
96
96
this would require providing a value of type Void.
97
97
98
- In principle, Rust can do some interesting analysees and optimizations based
98
+ In principle, Rust can do some interesting analyses and optimizations based
99
99
on this fact. For instance, ` Result<T, Void> ` could be represented as just ` T ` ,
100
- because the Err case doesn't actually exist. Also in principle the following
101
- could compile:
100
+ because the Err case doesn't actually exist. The following * could* also compile:
102
101
103
102
``` rust,ignore
104
103
enum Void {}
@@ -111,3 +110,9 @@ let Ok(num) = res;
111
110
112
111
But neither of these tricks work today, so all Void types get you today is
113
112
the ability to be confident that certain situations are statically impossible.
113
+
114
+ One final subtle detail about empty types is that raw pointers to them are
115
+ actually valid to construct, but dereferencing them is Undefined Behaviour
116
+ because that doesn't actually make sense. That is, you could model C's ` void * `
117
+ type with ` *const Void ` , but this doesn't necessarily gain anything over using
118
+ e.g. ` *const () ` , which * is* safe to randomly dereference.
You can’t perform that action at this time.
0 commit comments