Skip to content

Commit d56677a

Browse files
committed
Auto merge of #31931 - Luke-Nukem:master, r=steveklabnik
Refinement of paragraph referenced by [this issue](#31927). The paragraph in question had been adjusted already, but I've made some further clarifications which should help with readability and not leave the reader any `dangling pointers`.
2 parents d300e4f + edd5f33 commit d56677a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/doc/book/guessing-game.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -906,17 +906,17 @@ let guess: u32 = match guess.trim().parse() {
906906
Err(_) => continue,
907907
};
908908
```
909-
910909
This is how you generally move from ‘crash on error’ to ‘actually handle the
911-
error’, by switching from `expect()` to a `match` statement. The `Result`
912-
returned by `parse()` is an `enum` like `Ordering`, but in this case, each
913-
variant has some data associated with it: `Ok` is a success, and `Err` is a
910+
error’, by switching from `expect()` to a `match` statement. A `Result` is
911+
returned by `parse()`, this is an `enum` like `Ordering`, but in this case,
912+
each variant has some data associated with it: `Ok` is a success, and `Err` is a
914913
failure. Each contains more information: the successfully parsed integer, or an
915-
error type. In this case, we `match` on `Ok(num)`, which sets the inner value
916-
of the `Ok` to the name `num`, and then we return it on the right-hand
917-
side. In the `Err` case, we don’t care what kind of error it is, so we
918-
use `_` instead of a name. This ignores the error, and `continue` causes us
919-
to go to the next iteration of the `loop`.
914+
error type. In this case, we `match` on `Ok(num)`, which sets the name `num` to
915+
the unwrapped `Ok` value (ythe integer), and then we return it on the
916+
right-hand side. In the `Err` case, we don’t care what kind of error it is, so
917+
we just use the catch all `_` instead of a name. This catches everything that
918+
isn't `Ok`, and `continue` lets us move to the next iteration of the loop; in
919+
effect, this enables us to ignore all errors and continue with our program.
920920
921921
Now we should be good! Let’s try:
922922

0 commit comments

Comments
 (0)