File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -34,12 +34,12 @@ fn have_recipe(food: Food) -> Option<Food> {
3434 }
3535}
3636
37- // To make a dish, we need both the ingredients and the recipe .
37+ // To make a dish, we need both the recipe and the ingredients .
3838// We can represent the logic with a chain of `match`es:
3939fn cookable_v1(food: Food) -> Option<Food> {
40- match have_ingredients (food) {
40+ match have_recipe (food) {
4141 None => None,
42- Some(food) => match have_recipe (food) {
42+ Some(food) => match have_ingredients (food) {
4343 None => None,
4444 Some(food) => Some(food),
4545 },
@@ -48,7 +48,7 @@ fn cookable_v1(food: Food) -> Option<Food> {
4848
4949// This can conveniently be rewritten more compactly with `and_then()`:
5050fn cookable_v2(food: Food) -> Option<Food> {
51- have_ingredients (food).and_then(have_recipe )
51+ have_recipe (food).and_then(have_ingredients )
5252}
5353
5454fn eat(food: Food, day: Day) {
You can’t perform that action at this time.
0 commit comments