From ccce6d9491fcfdcaf0cc06b5a5bc488ca298d50f Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Wed, 6 Apr 2022 11:32:07 +1000 Subject: [PATCH] fieldless -> C-like --- src/expressions/operator-expr.md | 2 +- src/items/enumerations.md | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/expressions/operator-expr.md b/src/expressions/operator-expr.md index ab7d9cfc7..94bd0ca23 100644 --- a/src/expressions/operator-expr.md +++ b/src/expressions/operator-expr.md @@ -316,7 +316,7 @@ reference types and `mut` or `const` in pointer types. | Type of `e` | `U` | Cast performed by `e as U` | |-----------------------|-----------------------|----------------------------------| | Integer or Float type | Integer or Float type | Numeric cast | -| Field-less enum | Integer type | Enum cast | +| C-like enum | Integer type | Enum cast | | `bool` or `char` | Integer type | Primitive to integer cast | | `u8` | `char` | `u8` to `char` cast | | `*T` | `*V` where `V: Sized` \* | Pointer to pointer cast | diff --git a/src/items/enumerations.md b/src/items/enumerations.md index da0795ba2..dd44c3545 100644 --- a/src/items/enumerations.md +++ b/src/items/enumerations.md @@ -165,19 +165,19 @@ of the discriminant. #### Casting -If an enumeration is fieldless, then its discriminant can be directly -accessed with a [numeric cast]; e.g.: +If an enumeration is C-like (with no tuple and struct variants), then its +discriminant can be directly accessed with a [numeric cast]; e.g.: ```rust enum Enum { - Unit, - Tuple(), - Struct{}, + Foo, + Bar, + Baz, } -assert_eq!(0, Enum::Unit as isize); -assert_eq!(1, Enum::Tuple() as isize); -assert_eq!(2, Enum::Struct{} as isize); +assert_eq!(0, Enum::Foo as isize); +assert_eq!(1, Enum::Bar as isize); +assert_eq!(2, Enum::Baz as isize); ``` #### Pointer Casting