File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -316,7 +316,7 @@ reference types and `mut` or `const` in pointer types.
316316| Type of ` e ` | ` U ` | Cast performed by ` e as U ` |
317317| -----------------------| -----------------------| ----------------------------------|
318318| Integer or Float type | Integer or Float type | Numeric cast |
319- | Field-less enum | Integer type | Enum cast |
319+ | C-like enum | Integer type | Enum cast |
320320| ` bool ` or ` char ` | Integer type | Primitive to integer cast |
321321| ` u8 ` | ` char ` | ` u8 ` to ` char ` cast |
322322| ` *T ` | ` *V ` where ` V: Sized ` \* | Pointer to pointer cast |
Original file line number Diff line number Diff line change @@ -165,19 +165,19 @@ of the discriminant.
165165
166166#### Casting
167167
168- If an enumeration is fieldless, then its discriminant can be directly
169- accessed with a [ numeric cast] ; e.g.:
168+ If an enumeration is C-like (with no tuple and struct variants), then its
169+ discriminant can be directly accessed with a [ numeric cast] ; e.g.:
170170
171171``` rust
172172enum Enum {
173- Unit ,
174- Tuple () ,
175- Struct {} ,
173+ Foo ,
174+ Bar ,
175+ Baz ,
176176}
177177
178- assert_eq! (0 , Enum :: Unit as isize );
179- assert_eq! (1 , Enum :: Tuple () as isize );
180- assert_eq! (2 , Enum :: Struct {} as isize );
178+ assert_eq! (0 , Enum :: Foo as isize );
179+ assert_eq! (1 , Enum :: Bar as isize );
180+ assert_eq! (2 , Enum :: Baz as isize );
181181```
182182
183183#### Pointer Casting
You can’t perform that action at this time.
0 commit comments