mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Explain difference between star and underscore in patterns in the reference manual
This commit is contained in:
parent
b04b415e0d
commit
9280d0c090
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user