Skip to content

Update if-let.md #38436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/doc/book/if-let.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
% if let

`if let` allows you to combine `if` and `let` together to reduce the overhead
of certain kinds of pattern matches.
`if let` permits [patterns][pattern] matching within the condition of an [if][if] statement.
This allows us to reduce the overhead of certain kinds of [pattern][patterns] matches
and express them in a more convenient way.

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

[patterns]: patterns.html
[if]: if.html