From 56757566b34619fbd0792338de311adcde4d0e90 Mon Sep 17 00:00:00 2001 From: Charisee Chiw Date: Mon, 23 Jan 2023 03:58:49 -0800 Subject: [PATCH] Speaker notes for enums.md (#199) * Update enums.md * Update enums.md --- src/enums.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/enums.md b/src/enums.md index b2661bec..7a15d307 100644 --- a/src/enums.md +++ b/src/enums.md @@ -27,3 +27,15 @@ fn main() { println!("You got: {:?}", flip_coin()); } ``` + +
+ +Key Points: + +* Enumerations allow you to collect a set of values under one type +* This page offers an enum type `CoinFlip` with two variants `Heads` and `Tail`. You might note the namespace when using variants. +* This might be a good time to compare Structs and Enums: + * In both, you can have a simple version without fields (unit struct) or one with different types of fields (variant payloads). + * In both, associated functions are defined within an `impl` block. + * 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. +