File tree Expand file tree Collapse file tree 3 files changed +9
-3
lines changed
branches/stable/src/doc/tarpl Expand file tree Collapse file tree 3 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
29
29
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
30
30
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
31
31
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32
- refs/heads/stable: 14bc45477085222dcf2b87bef75ca3e7d0b5274a
32
+ refs/heads/stable: 5f02de3c226bce60c58ce2bc436e69c55b90a616
33
33
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
34
34
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
35
35
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e
Original file line number Diff line number Diff line change @@ -9,7 +9,9 @@ using the `as` keyword: `expr as Type`.
9
9
True casts generally revolve around raw pointers and the primitive numeric
10
10
types. Even though they're dangerous, these casts are * infallible* at runtime.
11
11
If a cast triggers some subtle corner case no indication will be given that
12
- this occurred. The cast will simply succeed.
12
+ this occurred. The cast will simply succeed. That said, casts must be valid
13
+ at the type level, or else they will be prevented statically. For instance,
14
+ ` 7u8 as bool ` will not compile.
13
15
14
16
That said, casts aren't ` unsafe ` because they generally can't violate memory
15
17
safety * on their own* . For instance, converting an integer to a raw pointer can
Original file line number Diff line number Diff line change @@ -12,7 +12,11 @@ An enum is said to be *C-like* if none of its variants have associated data.
12
12
For all these, individual fields are aligned to their preferred alignment. For
13
13
primitives this is usually equal to their size. For instance, a u32 will be
14
14
aligned to a multiple of 32 bits, and a u16 will be aligned to a multiple of 16
15
- bits. Composite structures will have a preferred alignment equal to the maximum
15
+ bits. Note that some primitives may be emulated on different platforms, and as
16
+ such may have strange alignment. For instance, a u64 on x86 may actually be
17
+ emulated as a pair of u32s, and thus only have 32-bit alignment.
18
+
19
+ Composite structures will have a preferred alignment equal to the maximum
16
20
of their fields' preferred alignment, and a size equal to a multiple of their
17
21
preferred alignment. This ensures that arrays of T can be correctly iterated
18
22
by offsetting by their size. So for instance,
You can’t perform that action at this time.
0 commit comments