Curriculum Data modeling
module 3 of 7
Data modeling
The Rust way to model domain data: structs with impl blocks, enums as tagged unions, pattern matching, Option, and destructuring. This is where TypeScript object and union habits become Rust algebraic data types.
Themes
Rust separates data declarations from method implementations. A
struct names fields; an impl block attaches constructors and
methods. Planned exercises: 1. choose struct declar…
Rust enums are real sum types: each variant can carry different data. This is the closest Rust analogue to TypeScript discriminated unions, but the compiler enforces exhaustiveness…
3.3
Pattern matching
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. re…
Rust does not have null; absence is Option<T>. TypeScript users
already know T | null; Rust makes the check mandatory before access.
Planned exercises: 1. choose Option<T>.…