From 9280d0c090ab62a1800c0e423b1da95b1e7db7ec Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 23 Apr 2012 19:22:24 -0700 Subject: [PATCH] Explain difference between star and underscore in patterns in the reference manual --- doc/rust.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/rust.md b/doc/rust.md index 90845294be4..4bf45788c47 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -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