Skip to content

Commit 6d62bd5

Browse files
committed
---
yaml --- r: 174281 b: refs/heads/snap-stage3 c: a2e277e h: refs/heads/master i: 174279: bbd9cbe v: v3
1 parent eab0eac commit 6d62bd5

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: a833337943300db1c310a4cf9c84b7b4ef4e9468
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 868669f420df66c6acd866391a855200efa4a5d6
4+
refs/heads/snap-stage3: a2e277edf49cb05e79c0346de9a145e4ce6754cb
55
refs/heads/try: 08f6380a9f0b866796080094f44fe25ea5636547
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/doc/reference.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,27 @@ a = Animal::Cat { name: "Spotty".to_string(), weight: 2.7 };
14131413
In this example, `Cat` is a _struct-like enum variant_,
14141414
whereas `Dog` is simply called an enum variant.
14151415

1416+
Enums have a discriminant. You can assign them explicitly:
1417+
1418+
```
1419+
enum Foo {
1420+
Bar = 123,
1421+
}
1422+
```
1423+
1424+
If a discriminant isn't assigned, they start at zero, and add one for each
1425+
variant, in order.
1426+
1427+
You can cast an enum to get this value:
1428+
1429+
```
1430+
# enum Foo { Bar = 123 }
1431+
let x = Foo::Bar as u32; // x is now 123u32
1432+
```
1433+
1434+
This only works as long as none of the variants have data attached. If
1435+
it were `Bar(i32)`, this is disallowed.
1436+
14161437
### Constant items
14171438

14181439
```{.ebnf .gram}

0 commit comments

Comments
 (0)