Skip to content

Commit f97e4d3

Browse files
committed
Auto merge of #30291 - Xmasreturns:patch-2, r=steveklabnik
Updated enums.md in the book
2 parents 9267a3a + 99fdf34 commit f97e4d3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/doc/book/enums.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
% Enums
22

3-
An `enum` in Rust is a type that represents data that could be one of
4-
several possible variants:
3+
An `enum` in Rust is a type that represents data that is one of
4+
several possible variants. Each variant in the `enum` can optionally
5+
have data associated with it:
56

67
```rust
78
enum Message {
@@ -12,9 +13,8 @@ enum Message {
1213
}
1314
```
1415

15-
Each variant can optionally have data associated with it. The syntax for
16-
defining variants resembles the syntaxes used to define structs: you can
17-
have variants with no data (like unit-like structs), variants with named
16+
The syntax for defining variants resembles the syntaxes used to define structs:
17+
you can have variants with no data (like unit-like structs), variants with named
1818
data, and variants with unnamed data (like tuple structs). Unlike
1919
separate struct definitions, however, an `enum` is a single type. A
2020
value of the enum can match any of the variants. For this reason, an
@@ -41,7 +41,7 @@ let y: BoardGameTurn = BoardGameTurn::Move { squares: 1 };
4141
Both variants are named `Move`, but since they’re scoped to the name of
4242
the enum, they can both be used without conflict.
4343

44-
A value of an enum type contains information about which variant it is,
44+
A value of an `enum` type contains information about which variant it is,
4545
in addition to any data associated with that variant. This is sometimes
4646
referred to as a ‘tagged union’, since the data includes a ‘tag’
4747
indicating what type it is. The compiler uses this information to
@@ -67,7 +67,7 @@ equality yet, but we’ll find out in the [`traits`][traits] section.
6767

6868
# Constructors as functions
6969

70-
An enum’s constructors can also be used like functions. For example:
70+
An `enum` constructor can also be used like a function. For example:
7171

7272
```rust
7373
# enum Message {
@@ -76,7 +76,7 @@ An enum’s constructors can also be used like functions. For example:
7676
let m = Message::Write("Hello, world".to_string());
7777
```
7878

79-
Is the same as
79+
is the same as
8080

8181
```rust
8282
# enum Message {

0 commit comments

Comments
 (0)