File tree 1 file changed +6
-2
lines changed
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,10 @@ However, `head` and `tail` do not alias each other: `head` points to the first
32
32
byte of ` u ` and ` tail ` points to the other seven bytes of ` u ` after it. Both ` head `
33
33
and ` tail ` alias ` s ` , any overlap is sufficient to count as an alias.
34
34
35
- * The span of a pointer or reference is the size of the value being pointed to or referenced.
35
+ The span of a pointer or reference is the size of the value being pointed to or referenced.
36
+
37
+ Depending on the type, you can determine the size as follows:
38
+
36
39
* For a type ` T ` that is [ ` Sized ` ] ( https://doc.rust-lang.org/core/marker/trait.Sized.html )
37
40
The span length of a pointer or reference to ` T ` is found with ` size_of::<T>() ` .
38
41
* When ` T ` is not ` Sized ` the story is a little tricker:
@@ -41,7 +44,8 @@ and `tail` alias `s`, any overlap is sufficient to count as an alias.
41
44
* If you have a pointer ` p ` you must unsafely convert that to a reference before
42
45
you can use ` size_of_val ` . There is not currently a safe way to determine the
43
46
span of a pointer to an unsized type.
44
- * The Data Layout chapter also has more information on the sizes of different types.
47
+
48
+ The Data Layout chapter also has more information on the sizes of different types.
45
49
46
50
One interesting side effect of these rules is that references and pointers to
47
51
Zero Sized Types _ never_ alias each other, because their span length is always 0
You can’t perform that action at this time.
0 commit comments