Files
rust-learning/exercises/02-engineering-2026/02-type-driven-design

02 — Type-Driven Design ("Make Illegal States Unrepresentable")

W erze AI system typów Rusta jest Twoją najskuteczniejszą specyfikacją. Zamiast pisać w komentarzu „email musi być poprawny” lub „nie dodawaj PLN do EUR”, wymuś to typami.

Zadania (src/lib.rs)

  1. Email::parse(raw: &str) -> Result<Email, ValidationError> — konstrukcja możliwa wyłącznie przez walidujący konstruktor (pole wewnętrzne prywatne).
  2. Money::checked_add(self, other: Money) -> Result<Money, CurrencyMismatch> — bezpieczne dodawanie kwot w groszach/centach z kontrolą waluty.

Uruchomienie testów

make test PKG=eng02-type-driven-design