6. Enums and Polymorphism - Rust's Tagged Unions
RustCurious
0:00 / 0:00
6. Enums and Polymorphism - Rust's Tagged Unions
3 688 просмотров · 5 мес. назад
RustCurious
2,89 тыс. подписчиков
3 688 просмотров · 5 мес. назад
Enums hold named alternatives (variants) with associated data. If you've never worked in a language with strong support for tagged unions, you'll wonder how you ever lived without them.
Complete Rust course: • All Lessons
Exercise source code:
🚀 https://rustcurious.com/6
Index:
0:00 Intro
2:19 OOP polymorphism
3:06 Tagged unions by hand
6:35 Enums with associated data
7:39 Matching on enums
8:57 Patterns that move out
9:43 Exhaustive matching and wildcards
10:28 Binding references in patterns
12:49 Deriving Clone
14:10 Make invalid states unrepresentable
15:04 Languages without tagged unions
19:47 Sum types
21:46 Polymorphism, open vs closed
22:33 Variant visibility
23:19 non_exhaustive
25:20 More enum syntax
26:22 Deriving Copy
26:41 Methods on enums
28:08 if-let: One pattern of interest
29:28 let-else: Match or diverge
31:19 while-let: Pattern as loop condition
31:42 Option, iterating a stream
32:41 Make invalid states unrepresentable (reprise)
33:12 Designing with enums
36:14 Nested enums, nested match expressions
37:27 Youtube analytics
38:26 Practice exercise
43:16 What's next