Skip to content

Commit fc4bb5f

Browse files
author
Luke Jones
committed
Correct line wrap
1 parent 981ac6d commit fc4bb5f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/doc/book/match.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,19 @@ patterns][patterns] that covers all the patterns that are possible here.
2828

2929
[patterns]: patterns.html
3030

31-
One of the many advantages of `match` is it enforces ‘exhaustiveness checking’. For example if we remove the last arm with the underscore `_`, the compiler will give us an error:
31+
One of the many advantages of `match` is it enforces ‘exhaustiveness checking’.
32+
For example if we remove the last arm with the underscore `_`, the compiler will
33+
give us an error:
3234

3335
```text
3436
error: non-exhaustive patterns: `_` not covered
3537
```
3638

37-
Rust is telling us that we forgot a value. The compiler infers from `x` that it can have any positive 32bit value; for example 1 to 2,147,483,647. The `_` acts as a 'catch-all', and will catch all possible values that *aren't* specified in an arm of `match`. As you can see with the previous example, we provide `match` arms for integers 1-5, if `x` is 6 or any other value, then it is caught by `_`.
39+
Rust is telling us that we forgot a value. The compiler infers from `x` that it
40+
can have any positive 32bit value; for example 1 to 2,147,483,647. The `_` acts
41+
as a 'catch-all', and will catch all possible values that *aren't* specified in
42+
an arm of `match`. As you can see with the previous example, we provide `match`
43+
arms for integers 1-5, if `x` is 6 or any other value, then it is caught by `_`.
3844

3945
`match` is also an expression, which means we can use it on the right-hand
4046
side of a `let` binding or directly where an expression is used:
@@ -52,7 +58,8 @@ let number = match x {
5258
};
5359
```
5460

55-
Sometimes it’s a nice way of converting something from one type to another; in this example the integers are converted to `String`.
61+
Sometimes it’s a nice way of converting something from one type to another; in
62+
this example the integers are converted to `String`.
5663

5764
# Matching on enums
5865

@@ -83,7 +90,8 @@ fn process_message(msg: Message) {
8390

8491
Again, the Rust compiler checks exhaustiveness, so it demands that you
8592
have a match arm for every variant of the enum. If you leave one off, it
86-
will give you a compile-time error unless you use `_` or provide all possible arms.
93+
will give you a compile-time error unless you use `_` or provide all possible
94+
arms.
8795

8896
Unlike the previous uses of `match`, you can’t use the normal `if`
8997
statement to do this. You can use the [`if let`][if-let] statement,

0 commit comments

Comments
 (0)