Skip to content

Commit 8c55428

Browse files
committed
Reword layout for arrays to reduce potential indexing confusion.
1 parent a514afe commit 8c55428

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/type-layout.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ at least equal to the size and alignment of a pointer.
7070
7171
## Array Layout
7272

73-
Arrays are laid out so that the `nth` element of the array is offset from the
74-
start of the array by `(n-1) * the size of the type` bytes i.e. the `1st`
75-
element has an offset of 0. An array of `[T; n]` has a size of
76-
`size_of::<T>() * n` and the same alignment of `T`.
73+
An array of `[T; N]` has a size of `size_of::<T>() * N` and the same alignment
74+
of `T`. Arrays are laid out so that the zero-indexed `n`th element of the array
75+
is offset from the start of the array by `n * size_of::<T>()` bytes.
7776

7877
## Slice Layout
7978

0 commit comments

Comments
 (0)