Skip to content

Commit ebf07da

Browse files
authored
Update if-let.md
1 parent 4495f7e commit ebf07da

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/doc/book/if-let.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
% if let
22

3-
`if let` is a figurative combination of `if` and `let`. `if let` does not literally
4-
mean `if` + `let` to the compiler; it has its own special meaning,which was added for
5-
convenience and as a way to reduce the overhead of certain kinds of pattern matches.
6-
3+
`if let` allows us to match [patterns][patterns] within the condition of an [if][if].
4+
As a consequence, we reduce the overhead of certain kinds of [pattern][patterns] matches
5+
and express them in a more convenient way.
76

87
For example, let’s say we have some sort of `Option<T>`. We want to call a function
98
on it if it’s `Some<T>`, but do nothing if it’s `None`. That looks like this:
@@ -82,3 +81,4 @@ while let Some(x) = v.pop() {
8281
```
8382

8483
[patterns]: patterns.html
84+
[if]: if.html

0 commit comments

Comments
 (0)