You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/enums.md
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -27,3 +27,15 @@ fn main() {
27
27
println!("You got: {:?}", flip_coin());
28
28
}
29
29
```
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.
0 commit comments