Skip to content

Commit 6453966

Browse files
authored
Merge pull request #2255 from seishun/patch-2
Improve sentence flow
2 parents da3648a + 5cb3aae commit 6453966

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/ch09-02-recoverable-errors-with-result.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -316,16 +316,16 @@ is an `Err`, the `Err` will be returned from the whole function as if we had
316316
used the `return` keyword so the error value gets propagated to the calling
317317
code.
318318

319-
There is a difference between what the `match` expression from Listing 9-6 and
320-
the `?` operator do: error values that have the `?` operator called on them go
321-
through the `from` function, defined in the `From` trait in the standard
322-
library, which is used to convert errors from one type into another. When the
323-
`?` operator calls the `from` function, the error type received is converted
324-
into the error type defined in the return type of the current function. This is
325-
useful when a function returns one error type to represent all the ways a
326-
function might fail, even if parts might fail for many different reasons. As
327-
long as each error type implements the `from` function to define how to convert
328-
itself to the returned error type, the `?` operator takes care of the
319+
There is a difference between what the `match` expression from Listing 9-6 does
320+
and what the `?` operator does: error values that have the `?` operator called
321+
on them go through the `from` function, defined in the `From` trait in the
322+
standard library, which is used to convert errors from one type into another.
323+
When the `?` operator calls the `from` function, the error type received is
324+
converted into the error type defined in the return type of the current
325+
function. This is useful when a function returns one error type to represent all
326+
the ways a function might fail, even if parts might fail for many different
327+
reasons. As long as each error type implements the `from` function to define how
328+
to convert itself to the returned error type, the `?` operator takes care of the
329329
conversion automatically.
330330

331331
In the context of Listing 9-7, the `?` at the end of the `File::open` call will

0 commit comments

Comments
 (0)