Skip to content

Commit

Permalink
fieldless -> C-like
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Apr 6, 2022
1 parent 7fe11e2 commit 2e93a1f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/expressions/operator-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
16 changes: 8 additions & 8 deletions src/items/enumerations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2e93a1f

Please sign in to comment.