@@ -378,47 +378,28 @@ enum Enum2<T> {
378
378
379
379
[niche]: ../glossary.html#niche
380
380
381
- ### Layout of single variant enums
381
+ ### Layout of enums with a single variant
382
382
383
383
> **NOTE**: the guarantees in this section have not been approved by an RFC process.
384
384
385
- **Single variant data -carrying*** enums without a `repr()` annotation have the
386
- same layout as the variant field. **Single variant fieldless ** enums have the
387
- same layout as a unit struct .
385
+ **Data -carrying** enums with a single variant without a `repr()` annotation have
386
+ the same layout as the variant field. **Fieldless ** enums with a single variant
387
+ have the same layout as a unit struct .
388
388
389
- Here :
389
+ For example, here :
390
390
391
391
``` rust
392
- # use std :: mem :: {size_of, align_of};
393
392
struct UnitStruct ;
394
- enum SingleVariantFieldless { FieldlessVariant }
395
- # fn main () {
396
- assert_eq! (size_of :: <SingleVariantFieldless >(), size_of :: <UnitStruct >());
397
- assert_eq! (align_of :: <SingleVariantFieldless >(), align_of :: <UnitStruct >());
398
- // assert_eq!(call_abi_of::<SingleVariantFieldless>(), call_abi_of::<UnitStruct>());
399
- // assert_eq!(niches_of::<SingleVariantFieldless>(), niches_of::<UnitStruct>());
400
- # }
401
- ```
402
-
403
- the single-variant fieldless enum ` SingleVariantFieldless ` has the same layout
404
- as ` UnitStruct ` .
393
+ enum FieldlessSingleVariant { FieldlessVariant }
405
394
406
- Here:
407
-
408
- ``` rust
409
- # use std :: mem :: {size_of, align_of};
410
395
struct SomeStruct { x : u32 }
411
- enum SingleVariantDataCarrying {
396
+ enum DataCarryingSingleVariant {
412
397
DataCarryingVariant (SomeStruct ),
413
398
}
414
- # fn main () {
415
- # assert_eq! (size_of :: <SingleVariantDataCarrying >(), size_of :: <SomeStruct >());
416
- # assert_eq! (align_of :: <SingleVariantDataCarrying >(), align_of :: <SomeStruct >());
417
- # }
418
399
```
419
400
420
- the single-variant data-carrying enum ` SingleVariantDataCarrying ` has the same
421
- layout as ` SomeStruct ` .
401
+ * ` FieldSingleVariant ` has the same layout as ` UnitStruct ` ,
402
+ * ` DataCarryingSingleVariant ` has the same layout as ` SomeStruct ` .
422
403
423
404
### Layout of multi-variant enums with one inhabited variant
424
405
0 commit comments