@@ -368,7 +368,7 @@ reference types and `mut` or `const` in pointer types.
368
368
| Type of ` e ` | ` U ` | Cast performed by ` e as U ` |
369
369
| -----------------------| -----------------------| ----------------------------------|
370
370
| Integer or Float type | Integer or Float type | Numeric cast |
371
- | [ Unit-only enum ] | Integer type | Enum cast |
371
+ | Enumeration | Integer type | Enum cast |
372
372
| ` bool ` or ` char ` | Integer type | Primitive to integer cast |
373
373
| ` u8 ` | ` char ` | ` u8 ` to ` char ` cast |
374
374
| ` *T ` | ` *V ` where ` V: Sized ` \* | Pointer to pointer cast |
@@ -430,6 +430,10 @@ halfway between two floating point numbers.
430
430
#### Enum cast
431
431
432
432
Casts an enum to its discriminant, then uses a numeric cast if needed.
433
+ Casting is limited to the following kinds of enumerations:
434
+
435
+ * [ Unit-only enums]
436
+ * [ Field-less enums] without [ explicit discriminants] , or where only unit-variants have explicit discriminants
433
437
434
438
#### Primitive to integer cast
435
439
@@ -632,6 +636,8 @@ See [this test] for an example of using this dependency.
632
636
633
637
[ copies or moves ] : ../expressions.md#moved-and-copied-types
634
638
[ dropping ] : ../destructors.md
639
+ [ explicit discriminants ] : ../items/enumerations.md#explicit-discriminants
640
+ [ field-less enums ] : ../items/enumerations.md#field-less-enum
635
641
[ grouped expression ] : grouped-expr.md
636
642
[ literal expression ] : literal-expr.md#integer-literal-expressions
637
643
[ logical and ] : ../types/boolean.md#logical-and
@@ -643,7 +649,7 @@ See [this test] for an example of using this dependency.
643
649
[ assignee expression ] : ../expressions.md#place-expressions-and-value-expressions
644
650
[ undefined behavior ] : ../behavior-considered-undefined.md
645
651
[ unit ] : ../types/tuple.md
646
- [ Unit-only enum ] : ../items/enumerations.md#unit-only-enum
652
+ [ Unit-only enums ] : ../items/enumerations.md#unit-only-enum
647
653
[ value expression ] : ../expressions.md#place-expressions-and-value-expressions
648
654
[ temporary value ] : ../expressions.md#temporaries
649
655
[ this test ] : https://github.com/rust-lang/rust/blob/1.58.0/src/test/ui/expr/compound-assignment/eval-order.rs
0 commit comments