diff --git a/src/ch09-02-recoverable-errors-with-result.md b/src/ch09-02-recoverable-errors-with-result.md index 80d07b3276..04be291eb2 100644 --- a/src/ch09-02-recoverable-errors-with-result.md +++ b/src/ch09-02-recoverable-errors-with-result.md @@ -470,13 +470,13 @@ and returns it. Of course, using `fs::read_to_string` doesn’t give us the opportunity to explain all the error handling, so we did it the longer way first. -#### The `?` Operator Can Only Be Used in Functions That Return `Result` +#### The `?` Operator Can Only Be Used in Functions That Return `Result` or `Option` The `?` operator can only be used in functions that have a return type of -`Result`, because it is defined to work in the same way as the `match` -expression we defined in Listing 9-6. The part of the `match` that requires a -return type of `Result` is `return Err(e)`, so the return type of the function -must be a `Result` to be compatible with this `return`. +`Result` or `Option`, because it is defined to work in the same way as the +`match` expression we defined in Listing 9-6. The part of the `match` that +requires a return type of `Result` is `return Err(e)`, so the return type of +the function must be a `Result` to be compatible with this `return`. Let’s look at what happens if we use the `?` operator in the `main` function, which you’ll recall has a return type of `()`: