Update if-let.md

This commit is contained in:
bluecereal 2017-01-21 02:24:48 -05:00 committed by GitHub
parent 4495f7e51e
commit ebf07da0a5

View File

@ -1,9 +1,8 @@
% if let
`if let` is a figurative combination of `if` and `let`. `if let` does not literally
mean `if` + `let` to the compiler; it has its own special meaning,which was added for
convenience and as a way to reduce the overhead of certain kinds of pattern matches.
`if let` allows us to match [patterns][patterns] within the condition of an [if][if].
As a consequence, we reduce the overhead of certain kinds of [pattern][patterns] matches
and express them in a more convenient way.
For example, lets say we have some sort of `Option<T>`. We want to call a function
on it if its `Some<T>`, but do nothing if its `None`. That looks like this:
@ -82,3 +81,4 @@ while let Some(x) = v.pop() {
```
[patterns]: patterns.html
[if]: if.html