chore: initialize containerized Rust learning workbook
This commit is contained in:
commit
05ffbd18bf
23 files changed
+549
No files matched your search
@@ -0,0 +1,16 @@
|
||||
# 03 — Struktury, Enumy i Pattern Matching
|
||||
|
||||
## Zakres
|
||||
* Definiowanie `struct` oraz metod w blokach `impl`
|
||||
* `enum` z danymi (*algebraic data types*)
|
||||
* `match`, `Option<T>`, `Result<T, E>`
|
||||
|
||||
## Zadania (`src/lib.rs`)
|
||||
1. `Rectangle::area(&self) -> u32` oraz `Rectangle::can_hold(&self, other: &Rectangle) -> bool`.
|
||||
2. `Shape::area(&self) -> f64` dla enuma `Shape` (`Circle(f64)` oraz `Rect { width: f64, height: f64 }`).
|
||||
3. `safe_divide(a: f64, b: f64) -> Option<f64>` — zwróć `None` przy dzieleniu przez `0.0`, w przeciwnym razie `Some(a / b)`.
|
||||
|
||||
## Uruchomienie testów
|
||||
```bash
|
||||
make test PKG=ex03-structs-enums
|
||||
```
|
||||
Reference in new issue
Block a user