Cooking food. Here, we showcase `map()` instead of `match` for case handling.
(chopped: Option<Chopped>)
| 29 | |
| 30 | // Cooking food. Here, we showcase `map()` instead of `match` for case handling. |
| 31 | fn cook(chopped: Option<Chopped>) -> Option<Cooked> { |
| 32 | chopped.map(|Chopped(food)| Cooked(food)) |
| 33 | } |
| 34 | |
| 35 | // A function to peel, chop, and cook food all in sequence. |
| 36 | // We chain multiple uses of `map()` to simplify the code. |