Add some more tests

This commit is contained in:
Vadim Petrochenkov 2015-09-11 14:03:38 +03:00
parent 5fa6e857c9
commit 605a472948
2 changed files with 34 additions and 2 deletions

View file

@ -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

View file

@ -13,11 +13,15 @@
struct Empty1 {}
struct Empty2;
struct Empty3 {}
const Empty3: Empty3 = Empty3 {};
fn main() {
let e1: Empty1 = Empty1 {};
let e2: Empty2 = Empty2 {};
let e2: Empty2 = Empty2;
let e3: Empty3 = Empty3 {};
let e3: Empty3 = Empty3;
match e1 {
Empty1 {} => ()
@ -28,4 +32,23 @@ fn main() {
match e2 {
Empty2 => ()
}
match e3 {
Empty3 {} => ()
}
match e3 {
Empty3 => ()
}
match e1 {
Empty1 { .. } => ()
}
match e2 {
Empty2 { .. } => ()
}
match e3 {
Empty3 { .. } => ()
}
let e11 = Empty1 { ..e1 };
let e22 = Empty2 { ..e2 };
let e33 = Empty3 { ..e3 };
}