Skip to content

Commit 5675756

Browse files
authored
Speaker notes for enums.md (#199)
* Update enums.md * Update enums.md
1 parent be2bb2d commit 5675756

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/enums.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,15 @@ fn main() {
2727
println!("You got: {:?}", flip_coin());
2828
}
2929
```
30+
31+
<details>
32+
33+
Key Points:
34+
35+
* Enumerations allow you to collect a set of values under one type
36+
* This page offers an enum type `CoinFlip` with two variants `Heads` and `Tail`. You might note the namespace when using variants.
37+
* This might be a good time to compare Structs and Enums:
38+
* In both, you can have a simple version without fields (unit struct) or one with different types of fields (variant payloads).
39+
* In both, associated functions are defined within an `impl` block.
40+
* You could even implement the different variants of an enum with separate structs but then they wouldn’t be the same type as they would if they were all defined in an enum.
41+
</details>

0 commit comments

Comments
 (0)