File tree Expand file tree Collapse file tree 3 files changed +9
-3
lines changed
branches/try/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 1
1
---
2
2
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
3
3
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4
- refs/heads/try: 14bc45477085222dcf2b87bef75ca3e7d0b5274a
4
+ refs/heads/try: 5f02de3c226bce60c58ce2bc436e69c55b90a616
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 @@ -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