typeover
rust curriculum

Curriculum Data modeling Pattern matching exercise 5 · fill-line

Pattern matching

About this theme

match is not a switch statement with nicer syntax. It destructures, binds names, checks exhaustiveness, and returns values. Planned exercises: 1. choose exhaustive match. 2. recognise wildcard _. 3. choose binding inside a variant. 4. fill a match arm. 5. fill an if let for one interesting case. 6. write a match returning a string. 7. write destructuring for a struct variant. 8. translate TS discriminant checks. 9. fix a non-exhaustive match.