@@ -470,13 +470,13 @@ and returns it. Of course, using `fs::read_to_string` doesn’t give us the
470470opportunity to explain all the error handling, so we did it the longer way
471471first.
472472
473- #### The ` ? ` Operator Can Only Be Used in Functions That Return ` Result `
473+ #### The ` ? ` Operator Can Be Used in Functions That Return ` Result `
474474
475- The ` ? ` operator can only be used in functions that have a return type of
475+ The ` ? ` operator can be used in functions that have a return type of
476476` Result ` , because it is defined to work in the same way as the ` match `
477477expression we defined in Listing 9-6. The part of the ` match ` that requires a
478478return type of ` Result ` is ` return Err(e) ` , so the return type of the function
479- must be a ` Result ` to be compatible with this ` return ` .
479+ can be a ` Result ` to be compatible with this ` return ` .
480480
481481Let’s look at what happens if we use the ` ? ` operator in the ` main ` function,
482482which you’ll recall has a return type of ` () ` :
@@ -505,8 +505,9 @@ error[E0277]: the `?` operator can only be used in a function that returns
505505```
506506
507507This error points out that we’re only allowed to use the ` ? ` operator in a
508- function that returns ` Result<T, E> ` . When you’re writing code in a function
509- that doesn’t return ` Result<T, E> ` , and you want to use ` ? ` when you call other
508+ function that returns ` Result ` or ` Option ` or another type that implements
509+ ` std::ops::Try ` . When you’re writing code in a function
510+ that doesn’t return one of these types, and you want to use ` ? ` when you call other
510511functions that return ` Result<T, E> ` , you have two choices to fix this problem.
511512One technique is to change the return type of your function to be `Result<T,
512513E>` if you have no restrictions preventing that. The other technique is to use
0 commit comments