blob: 6dca5d60f11114b1fc7952fd6eb8976048466999 [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 Walton206ab892013-05-25 02:35:2911use std::io;
12
Patrick Walton142dbd62013-03-23 01:52:0413static x : [int, ..4] = [1,2,3,4];
Patrick Walton85c9fc62013-03-22 21:00:1514static p : int = x[2];
15static y : &'static [int] = &[1,2,3,4];
16static q : int = y[2];
Graydon Hoarea0e3a2a2012-08-09 02:41:5017
Tim Chevalier6d4907a2013-01-26 06:46:3218struct S {a: int, b: int}
19
Patrick Walton85c9fc62013-03-22 21:00:1520static s : S = S {a: 10, b: 20};
21static t : int = s.b;
Graydon Hoarea0e3a2a2012-08-09 02:41:5022
Tim Chevalier6d4907a2013-01-26 06:46:3223struct K {a: int, b: int, c: D}
24struct D { d: int, e: int }
25
Patrick Walton85c9fc62013-03-22 21:00:1526static k : K = K {a: 10, b: 20, c: D {d: 30, e: 40}};
27static m : int = k.c.e;
Niko Matsakis5e36a992012-08-28 22:54:4528
Graydon Hoare89c8ef72013-02-02 03:43:1729pub fn main() {
Birunthan Mohanathas206ae572013-07-22 16:04:5130 printfln!(p);
31 printfln!(q);
32 printfln!(t);
Corey Richardsoncc57ca02013-05-19 02:02:4533 assert_eq!(p, 3);
34 assert_eq!(q, 3);
35 assert_eq!(t, 20);
Ben Striegelac81fff2012-10-10 04:28:0436}