diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2012-08-07 17:11:43 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2012-08-07 17:31:26 -0700 |
| commit | 175be53e3f62664e445a57c2ad9e23f4bcb296b2 (patch) | |
| tree | 92dcb5d75cb0b8a32c7aacd4c83f3c9ff99df784 /src/test/run-pass/const-struct.rs | |
| parent | 4be8239ac2fe2209dd4f19279151aa18792e6c4a (diff) | |
| download | rust-175be53e3f62664e445a57c2ad9e23f4bcb296b2.tar.gz rust-175be53e3f62664e445a57c2ad9e23f4bcb296b2.zip | |
Translate const structs.
Diffstat (limited to 'src/test/run-pass/const-struct.rs')
| -rw-r--r-- | src/test/run-pass/const-struct.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/run-pass/const-struct.rs b/src/test/run-pass/const-struct.rs new file mode 100644 index 00000000000..132ecb935cf --- /dev/null +++ b/src/test/run-pass/const-struct.rs @@ -0,0 +1,14 @@ + +struct foo { a: int; b: int; c: int; } + +const x : foo = foo { a:1, b:2, c: 3 }; +const y : foo = foo { b:2, c:3, a: 1 }; +const z : &foo = &foo { a: 10, b: 22, c: 12 }; + +fn main() { + assert x.b == 2; + assert x == y; + assert z.b == 22; + io::println(fmt!{"0x%x", x.b as uint}); + io::println(fmt!{"0x%x", z.c as uint}); +} |
