Skip to content

Commit 3731a86

Browse files
authored
enums can now be #[repr(transparent)]
1 parent 11e893f commit 3731a86

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/type-layout.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,14 @@ Like all ways to create undefined behavior in safe Rust, this is a bug.
332332

333333
### The `transparent` Representation
334334

335-
The `transparent` representation can only be used on `struct`s that have:
335+
The `transparent` representation can only be used on a [`struct`][structs] that has,
336+
or an [`enum`][enumerations] with a single variant which has:
336337

337338
- a single field with non-zero size, and
338339
- any number of fields with size 0 and alignment 1 (e.g. [`PhantomData<T>`]).
339340

340-
Structs with this representation have the same layout and ABI as the single
341-
non-zero sized field.
341+
Structs and enums with this representation have the same layout and ABI
342+
as the single non-zero sized field.
342343

343344
This is different than the `C` representation because
344345
a struct with the `C` representation will always have the ABI of a `C` `struct`
@@ -355,11 +356,13 @@ used with any other representation.
355356
[`Sized`]: ../std/marker/trait.Sized.html
356357
[dynamically sized types]: dynamically-sized-types.md
357358
[C-like enumerations]: items/enumerations.md#custom-discriminant-values-for-field-less-enumerations
359+
[enumerations]: items/enumerations.md
358360
[zero-variant enumerations]: items/enumerations.md#zero-variant-enums
359361
[undefined behavior]: behavior-considered-undefined.md
360362
[27060]: https://github.com/rust-lang/rust/issues/27060
361363
[`PhantomData<T>`]: special-types-and-traits.md#phantomdatat
362364
[Default]: #the-default-representation
363365
[`C`]: #the-c-representation
364366
[primitive representations]: #primitive-representations
367+
[structs]: items/structs.md
365368
[`transparent`]: #the-transparent-representation

0 commit comments

Comments
 (0)