Skip to content

Commit 18d13e7

Browse files
authored
Merge pull request #1260 from joshlf/patch-2
Clarify that 0 is a valid multiple of a type's alignment
2 parents 9f844c6 + 33cc59a commit 18d13e7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/type-layout.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ The alignment of a value can be checked with the [`align_of_val`] function.
2020

2121
The *size* of a value is the offset in bytes between successive elements in an
2222
array with that item type including alignment padding. The size of a value is
23-
always a multiple of its alignment. The size of a value can be checked with the
24-
[`size_of_val`] function.
23+
always a multiple of its alignment. Note that some types are zero-sized; 0 is
24+
considered a multiple of any alignment (for example, on some platforms, the type
25+
`[u16; 0]` has size 0 and alignment 2). The size of a value can be checked with
26+
the [`size_of_val`] function.
2527

2628
Types where all values have the same size and alignment, and both are known at
2729
compile time, implement the [`Sized`] trait and can be checked with the

0 commit comments

Comments
 (0)