@@ -2186,7 +2186,7 @@ match_pat : pat [ ".." pat ] ? [ "if" expr ] ;
21862186
21872187A ` match ` expression branches on a * pattern* . The exact form of matching that
21882188occurs depends on the pattern. Patterns consist of some combination of
2189- literals, destructured enum constructors, records and tuples, variable binding
2189+ literals, destructured enum constructors, structures, records and tuples, variable binding
21902190specifications, wildcards (` * ` ), and placeholders (` _ ` ). A ` match ` expression has a * head
21912191expression* , which is the value to compare to the patterns. The type of the
21922192patterns must equal the type of the head expression.
@@ -2196,19 +2196,19 @@ In a pattern whose head expression has an `enum` type, a placeholder (`_`) stand
21962196variant. For example:
21972197
21982198~~~~
2199- enum list <X> { nil, cons (X, @list <X>) }
2199+ enum List <X> { Nil, Cons (X, @List <X>) }
22002200
2201- let x: list <int> = cons (10, @cons (11, @nil ));
2201+ let x: List <int> = Cons (10, @Cons (11, @Nil ));
22022202
22032203match x {
2204- cons (_, @nil ) => fail ~"singleton list",
2205- cons (*) => return,
2206- nil => fail ~"empty list"
2204+ Cons (_, @Nil ) => fail ~"singleton list",
2205+ Cons (*) => return,
2206+ Nil => fail ~"empty list"
22072207}
22082208~~~~
22092209
2210- The first pattern matches lists constructed by applying ` cons ` to any head value, and a
2211- tail value of ` @nil ` . The second pattern matches ` any ` list constructed with ` cons ` ,
2210+ The first pattern matches lists constructed by applying ` Cons ` to any head value, and a
2211+ tail value of ` @Nil ` . The second pattern matches _ any _ list constructed with ` Cons ` ,
22122212ignoring the values of its arguments. The difference between ` _ ` and ` * ` is that the pattern ` C(_) ` is only type-correct if
22132213` C ` has exactly one argument, while the pattern ` C(*) ` is type-correct for any enum variant ` C ` , regardless of how many arguments ` C ` has.
22142214
@@ -2225,18 +2225,18 @@ An example of an `match` expression:
22252225# fn process_pair(a: int, b: int) { }
22262226# fn process_ten() { }
22272227
2228- enum list <X> { nil, cons (X, @list <X>) }
2228+ enum List <X> { Nil, Cons (X, @List <X>) }
22292229
2230- let x: list <int> = cons (10, @cons (11, @nil ));
2230+ let x: List <int> = Cons (10, @Cons (11, @Nil ));
22312231
22322232match x {
2233- cons (a, @cons (b, _)) => {
2233+ Cons (a, @Cons (b, _)) => {
22342234 process_pair(a,b);
22352235 }
2236- cons (10, _) => {
2236+ Cons (10, _) => {
22372237 process_ten();
22382238 }
2239- nil => {
2239+ Nil => {
22402240 return;
22412241 }
22422242 _ => {
@@ -2245,7 +2245,7 @@ match x {
22452245}
22462246~~~~
22472247
2248- Records can also be pattern-matched and their fields bound to variables.
2248+ Records and structures can also be pattern-matched and their fields bound to variables.
22492249When matching fields of a record, the fields being matched are specified
22502250first, then a placeholder (` _ ` ) represents the remaining fields.
22512251
0 commit comments