Make an example more clear with sample code.

Fixes #11113.
This commit is contained in:
Steve Klabnik 2014-06-23 14:02:42 -04:00
parent d77cb22bb6
commit 53627dd1f2
1 changed files with 8 additions and 3 deletions

View File

@ -559,9 +559,14 @@ tuple, introducing two variables at once: `a` and `b`.
let (a, b) = get_tuple_of_two_ints();
~~~~
Let bindings only work with _irrefutable_ patterns: that is, patterns
that can never fail to match. This excludes `let` from matching
literals and most `enum` variants.
Let bindings only work with _irrefutable_ patterns: that is, patterns that can
never fail to match. This excludes `let` from matching literals and most `enum`
variants as binding patterns, since most such patterns are not irrefutable. For
example, this will not compile:
~~~~{ignore}
let (a, 2) = (1, 2);
~~~~
## Loops