diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-12-18 13:43:46 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-12-18 20:02:14 +0530 |
| commit | 4f8b32c96fd346716d55ceedaac490ff0d7fd463 (patch) | |
| tree | 29e1c5cecac1c57a4b577e906508335865f1eea5 /src/doc | |
| parent | e9166766bd92fae9fb47550ee50ec43eb6aebae5 (diff) | |
| parent | 2a23e4a5b02bfb80d71becd8397e467838c94424 (diff) | |
| download | rust-4f8b32c96fd346716d55ceedaac490ff0d7fd463.tar.gz rust-4f8b32c96fd346716d55ceedaac490ff0d7fd463.zip | |
Rollup merge of #30447 - Xmasreturns:Docu, r=steveklabnik
Added sentences for description of code and changed x in the example to an int
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/book/patterns.md | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/doc/book/patterns.md b/src/doc/book/patterns.md index 8f4a7a43955..43f1bd2529f 100644 --- a/src/doc/book/patterns.md +++ b/src/doc/book/patterns.md @@ -27,7 +27,7 @@ There’s one pitfall with patterns: like anything that introduces a new binding they introduce shadowing. For example: ```rust -let x = 'x'; +let x = 1; let c = 'c'; match c { @@ -41,12 +41,14 @@ This prints: ```text x: c c: c -x: x +x: 1 ``` In other words, `x =>` matches the pattern and introduces a new binding named -`x` that’s in scope for the match arm. Because we already have a binding named -`x`, this new `x` shadows it. +`x`. This new binding is in scope for the match arm and takes on the value of +`c`. Notice that the value of `x` outside the scope of the match has no bearing +on the value of `x` within it. Because we already have a binding named `x`, this +new `x` shadows it. # Multiple patterns |
