diff options
| author | bors <bors@rust-lang.org> | 2013-11-28 20:31:39 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-11-28 20:31:39 -0800 |
| commit | bf6964ecb67f4ffce6be75130ab7a3be793960ff (patch) | |
| tree | ddf8aabea4d05b3ae0cb977cc1a466526f871b06 /doc | |
| parent | 90d06ecf6b26e949921778f0d479ea1532077200 (diff) | |
| parent | ab387a68388974a432951e806851936898907fd0 (diff) | |
| download | rust-bf6964ecb67f4ffce6be75130ab7a3be793960ff.tar.gz rust-bf6964ecb67f4ffce6be75130ab7a3be793960ff.zip | |
auto merge of #10709 : alexcrichton/rust/snapshot, r=pcwalton
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/rust.md | 6 | ||||
| -rw-r--r-- | doc/tutorial.md | 12 |
2 files changed, 9 insertions, 9 deletions
diff --git a/doc/rust.md b/doc/rust.md index 2a4a066c020..a25f19371bd 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -2820,7 +2820,7 @@ expression*, which is the value to compare to the patterns. The type of the patterns must equal the type of the head expression. In a pattern whose head expression has an `enum` type, a placeholder (`_`) stands for a -*single* data field, whereas a wildcard `*` stands for *all* the fields of a particular +*single* data field, whereas a wildcard `..` stands for *all* the fields of a particular variant. For example: ~~~~ @@ -2830,7 +2830,7 @@ let x: List<int> = Cons(10, @Cons(11, @Nil)); match x { Cons(_, @Nil) => fail!("singleton list"), - Cons(*) => return, + Cons(..) => return, Nil => fail!("empty list") } ~~~~ @@ -2838,7 +2838,7 @@ match x { The first pattern matches lists constructed by applying `Cons` to any head value, and a tail value of `@Nil`. The second pattern matches _any_ list constructed with `Cons`, ignoring the values of its arguments. The difference between `_` and `*` is that the pattern `C(_)` is only type-correct if -`C` has exactly one argument, while the pattern `C(*)` is type-correct for any enum variant `C`, regardless of how many arguments `C` has. +`C` has exactly one argument, while the pattern `C(..)` is type-correct for any enum variant `C`, regardless of how many arguments `C` has. To execute an `match` expression, first the head expression is evaluated, then its value is sequentially compared to the patterns in the arms until a match diff --git a/doc/tutorial.md b/doc/tutorial.md index 1559033a582..c82f99772c9 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -606,8 +606,8 @@ match mypoint { In general, the field names of a struct do not have to appear in the same order they appear in the type. When you are not interested in all -the fields of a struct, a struct pattern may end with `, _` (as in -`Name { field1, _ }`) to indicate that you're ignoring all other fields. +the fields of a struct, a struct pattern may end with `, ..` (as in +`Name { field1, .. }`) to indicate that you're ignoring all other fields. Additionally, struct fields have a shorthand matching form that simply reuses the field name as the binding name. @@ -615,7 +615,7 @@ reuses the field name as the binding name. # struct Point { x: f64, y: f64 } # let mypoint = Point { x: 0.0, y: 0.0 }; match mypoint { - Point { x, _ } => { println(x.to_str()) } + Point { x, .. } => { println(x.to_str()) } } ~~~ @@ -696,7 +696,7 @@ fn area(sh: Shape) -> f64 { ~~~~ You can write a lone `_` to ignore an individual field, and can -ignore all fields of a variant like: `Circle(*)`. As in their +ignore all fields of a variant like: `Circle(..)`. As in their introduction form, nullary enum patterns are written without parentheses. @@ -725,7 +725,7 @@ enum Shape { } fn area(sh: Shape) -> f64 { match sh { - Circle { radius: radius, _ } => f64::consts::PI * square(radius), + Circle { radius: radius, .. } => f64::consts::PI * square(radius), Rectangle { top_left: top_left, bottom_right: bottom_right } => { (bottom_right.x - top_left.x) * (top_left.y - bottom_right.y) } @@ -1698,7 +1698,7 @@ a function that returns `Option<T>` instead of `T`. fn radius(shape: Shape) -> Option<f64> { match shape { Circle(_, radius) => Some(radius), - Rectangle(*) => None + Rectangle(..) => None } } ~~~~ |
