diff --git a/src/error/option_unwrap/and_then.md b/src/error/option_unwrap/and_then.md index aab95cac30..99d8133ac6 100644 --- a/src/error/option_unwrap/and_then.md +++ b/src/error/option_unwrap/and_then.md @@ -34,12 +34,12 @@ fn have_recipe(food: Food) -> Option { } } -// To make a dish, we need both the ingredients and the recipe. +// To make a dish, we need both the recipe and the ingredients. // We can represent the logic with a chain of `match`es: fn cookable_v1(food: Food) -> Option { - match have_ingredients(food) { + match have_recipe(food) { None => None, - Some(food) => match have_recipe(food) { + Some(food) => match have_ingredients(food) { None => None, Some(food) => Some(food), }, @@ -48,7 +48,7 @@ fn cookable_v1(food: Food) -> Option { // This can conveniently be rewritten more compactly with `and_then()`: fn cookable_v2(food: Food) -> Option { - have_ingredients(food).and_then(have_recipe) + have_recipe(food).and_then(have_ingredients) } fn eat(food: Food, day: Day) {