@@ -351,47 +351,28 @@ enum Enum1<T> {
351
351
}
352
352
```
353
353
354
- ### Layout of single variant enums
354
+ ### Layout of enums with a single variant
355
355
356
356
> **NOTE**: the guarantees in this section have not been approved by an RFC process.
357
357
358
- **Single variant data -carrying*** enums without a `repr()` annotation have the
359
- same layout as the variant field. **Single variant fieldless ** enums have the
360
- same layout as a unit struct .
358
+ **Data -carrying** enums with a single variant without a `repr()` annotation have
359
+ the same SAFNC- layout as the variant field. **Fieldless ** enums with a single variant
360
+ have the same SAFNC- layout as a unit struct .
361
361
362
- Here :
362
+ For example, here :
363
363
364
364
``` rust
365
- # use std :: mem :: {size_of, align_of};
366
365
struct UnitStruct ;
367
- enum SingleVariantFieldless { FieldlessVariant }
368
- # fn main () {
369
- assert_eq! (size_of :: <SingleVariantFieldless >(), size_of :: <UnitStruct >());
370
- assert_eq! (align_of :: <SingleVariantFieldless >(), align_of :: <UnitStruct >());
371
- // assert_eq!(call_abi_of::<SingleVariantFieldless>(), call_abi_of::<UnitStruct>());
372
- // assert_eq!(niches_of::<SingleVariantFieldless>(), niches_of::<UnitStruct>());
373
- # }
374
- ```
375
-
376
- the single-variant fieldless enum ` SingleVariantFieldless ` has the same layout
377
- as ` UnitStruct ` .
366
+ enum FieldlessSingleVariant { FieldlessVariant }
378
367
379
- Here:
380
-
381
- ``` rust
382
- # use std :: mem :: {size_of, align_of};
383
368
struct SomeStruct { x : u32 }
384
- enum SingleVariantDataCarrying {
369
+ enum DataCarryingSingleVariant {
385
370
DataCarryingVariant (SomeStruct ),
386
371
}
387
- # fn main () {
388
- # assert_eq! (size_of :: <SingleVariantDataCarrying >(), size_of :: <SomeStruct >());
389
- # assert_eq! (align_of :: <SingleVariantDataCarrying >(), align_of :: <SomeStruct >());
390
- # }
391
372
```
392
373
393
- the single-variant data-carrying enum ` SingleVariantDataCarrying ` has the same
394
- layout as ` SomeStruct ` .
374
+ * ` FieldSingleVariant ` has the same SAFNC-layout as ` UnitStruct ` ,
375
+ * ` DataCarryingSingleVariant ` has the same SAFNC- layout as ` SomeStruct ` .
395
376
396
377
### Layout of multi-variant enums with one inhabited variant
397
378
0 commit comments