diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-01-19 01:22:19 -0800 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-01-19 01:22:43 -0800 |
| commit | 90cd795b8bc22719e43183444d1963eda5161de6 (patch) | |
| tree | e66d772a931fe274800edb006fe21aa4f1e6a1a1 /doc/tutorial/data.md | |
| parent | d887c0e7892a97af5464468c50887dea6e6dc91e (diff) | |
| download | rust-90cd795b8bc22719e43183444d1963eda5161de6.tar.gz rust-90cd795b8bc22719e43183444d1963eda5161de6.zip | |
Update docs to reflect pattern syntax change
Diffstat (limited to 'doc/tutorial/data.md')
| -rw-r--r-- | doc/tutorial/data.md | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/doc/tutorial/data.md b/doc/tutorial/data.md index 600589d07b7..79a0cb85ac5 100644 --- a/doc/tutorial/data.md +++ b/doc/tutorial/data.md @@ -155,18 +155,16 @@ patterns, as in this definition of `area`: } } -For variants without arguments, you have to write `variantname.` (with -a dot at the end) to match them in a pattern. This to prevent -ambiguity between matching a variant name and binding a new variable. +Another example: # type point = {x: float, y: float}; # enum direction { north; east; south; west; } fn point_from_direction(dir: direction) -> point { alt dir { - north. { {x: 0f, y: 1f} } - east. { {x: 1f, y: 0f} } - south. { {x: 0f, y: -1f} } - west. { {x: -1f, y: 0f} } + north { {x: 0f, y: 1f} } + east { {x: 1f, y: 0f} } + south { {x: 0f, y: -1f} } + west { {x: -1f, y: 0f} } } } |
