blob: b31dcc83428400c7c770aeaf29d44fefc711feb0 [file] [log] [blame]
Graydon Hoared1affff2012-12-11 01:32:481// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
Patrick Walton142dbd62013-03-23 01:52:0411static x : [int, ..4] = [1,2,3,4];
Patrick Walton85c9fc62013-03-22 21:00:1512static p : int = x[2];
13static y : &'static [int] = &[1,2,3,4];
14static q : int = y[2];
Graydon Hoarea0e3a2a2012-08-09 02:41:5015
Tim Chevalier6d4907a2013-01-26 06:46:3216struct S {a: int, b: int}
17
Patrick Walton85c9fc62013-03-22 21:00:1518static s : S = S {a: 10, b: 20};
19static t : int = s.b;
Graydon Hoarea0e3a2a2012-08-09 02:41:5020
Tim Chevalier6d4907a2013-01-26 06:46:3221struct K {a: int, b: int, c: D}
22struct D { d: int, e: int }
23
Patrick Walton85c9fc62013-03-22 21:00:1524static k : K = K {a: 10, b: 20, c: D {d: 30, e: 40}};
25static m : int = k.c.e;
Niko Matsakis5e36a992012-08-28 22:54:4526
Graydon Hoare89c8ef72013-02-02 03:43:1727pub fn main() {
Birunthan Mohanathas206ae572013-07-22 16:04:5128 printfln!(p);
29 printfln!(q);
30 printfln!(t);
Corey Richardsoncc57ca02013-05-19 02:02:4531 assert_eq!(p, 3);
32 assert_eq!(q, 3);
33 assert_eq!(t, 20);
Ben Striegelac81fff2012-10-10 04:28:0434}