Skip to content

Commit

Permalink
Explain difference between star and underscore in patterns in the ref…
Browse files Browse the repository at this point in the history
…erence manual
  • Loading branch information
catamorphism committed Apr 24, 2012
1 parent b04b415 commit 9280d0c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,8 @@ alt 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.
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.

To execute an `alt` expression, first the head expression is evaluated, then
its value is sequentially compared to the patterns in the arms until a match
Expand Down

0 comments on commit 9280d0c

Please sign in to comment.