about summary refs log tree commit diff
path: root/doc
diff options
context:
space:
mode:
authorJesse Jones <jesse9jones@gmail.com>2012-11-18 15:15:12 -0800
committerJesse Jones <jesse9jones@gmail.com>2012-11-18 15:15:12 -0800
commite46de5381b7d16797ff690e7770acf8ba49ba8c3 (patch)
tree6e587e59b79e671b1d2d725197c3e88c61478725 /doc
parent67d421d62dcfe5ee6c45970aaf25ddaf4cc577df (diff)
Moved the matching structs example next to the prose talking about struct matching
Diffstat (limited to 'doc')
-rw-r--r--doc/rust.md22
1 files changed, 11 insertions, 11 deletions
diff --git a/doc/rust.md b/doc/rust.md
index ac3c16b6e85..dddd372dcc8 100644
--- a/doc/rust.md
+++ b/doc/rust.md
@@ -2174,17 +2174,6 @@ Records and structures can also be pattern-matched and their fields bound to var
 When matching fields of a record,
 the fields being matched are specified first,
 then a placeholder (`_`) represents the remaining fields.
-
-A pattern that's just a variable binding,
-like `Nil` in the previous answer,
-could either refer to an enum variant that's in scope,
-or bind a new variable.
-The compiler resolves this ambiguity by forbidding variable bindings that occur in ```match``` patterns from shadowing names of variants that are in scope.
-For example, wherever ```List``` is in scope,
-a ```match``` pattern would not be able to bind ```Nil``` as a new name.
-The compiler interprets a variable pattern `x` as a binding _only_ if there is no variant named `x` in scope.
-A convention you can use to avoid conflicts is simply to name variants with upper-case letters,
-and local variables with lower-case letters.
  
 ~~~~
 # type options = {choose: bool, size: ~str};
@@ -2217,6 +2206,17 @@ fn main() {
 }
 ~~~~
 
+A pattern that's just a variable binding,
+like `Nil` in the previous answer,
+could either refer to an enum variant that's in scope,
+or bind a new variable.
+The compiler resolves this ambiguity by forbidding variable bindings that occur in ```match``` patterns from shadowing names of variants that are in scope.
+For example, wherever ```List``` is in scope,
+a ```match``` pattern would not be able to bind ```Nil``` as a new name.
+The compiler interprets a variable pattern `x` as a binding _only_ if there is no variant named `x` in scope.
+A convention you can use to avoid conflicts is simply to name variants with upper-case letters,
+and local variables with lower-case letters.
+
 Multiple match patterns may be joined with the `|` operator.  A
 range of values may be specified with `..`. For example: