diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2015-09-11 14:03:38 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2015-09-18 15:26:09 +0300 |
| commit | 605a4729481db73473dc37f09f840da6ec6173ab (patch) | |
| tree | 08c547b85020fbc41bcadb1f0771a74acfd4fd85 /src/doc/reference.md | |
| parent | 5fa6e857c9f43a69661ebca278c99155ee7d5db7 (diff) | |
| download | rust-605a4729481db73473dc37f09f840da6ec6173ab.tar.gz rust-605a4729481db73473dc37f09f840da6ec6173ab.zip | |
Add some more tests
Diffstat (limited to 'src/doc/reference.md')
| -rw-r--r-- | src/doc/reference.md | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/doc/reference.md b/src/doc/reference.md index 18feebf3d56..95a58686cf2 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -1178,11 +1178,20 @@ let px: i32 = match p { Point(x, _) => x }; ``` A _unit-like struct_ is a structure without any fields, defined by leaving off -the list of fields entirely. Such types will have a single value. For example: +the list of fields entirely. Such structure implicitly defines a constant of +its type with the same name. For example: ``` struct Cookie; -let c = [Cookie, Cookie, Cookie, Cookie]; +let c = [Cookie, Cookie {}, Cookie, Cookie {}]; +``` + +is equivalent to + +``` +struct Cookie {} +const Cookie: Cookie = Cookie {}; +let c = [Cookie, Cookie {}, Cookie, Cookie {}]; ``` The precise memory layout of a structure is not specified. One can specify a |
