Skip to content

Commit 774b125

Browse files
committed
give example where it can be more efficient
1 parent 2c6a52f commit 774b125

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

reference/src/representation/enums.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Note that the `TwoCasesVariantA` and `TwoCasesVariantB` structs are
189189
`#[repr(C)]`; this is needed to ensure that the `TwoCasesTag` value
190190
appears at offset 0 in both cases, so that we can read it to determine
191191
the current variant.
192-
192+
193193
#### C-compatible representation selected
194194

195195
When the `#[repr]` tag includes `C`, e.g., `#[repr(C)]` or `#[repr(C,
@@ -203,7 +203,9 @@ variants.
203203

204204
This layout, while more compatible and arguably more obvious, is also
205205
less efficient than the non-C compatible layout in some cases in terms
206-
of total size.
206+
of total size. For example, the `TwoCases` example given in the
207+
preivous section only occupies 4 bytes with `#[repr(u8)]`, but would
208+
occupy 6 bytes with `#[repr(C, u8)]`, as more padding is required.
207209

208210
**Example.** The following enum:
209211

0 commit comments

Comments
 (0)