]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/const-fields-and-indexing.rs
cleanup: s/impl Copy/#[derive(Copy)]/g
[rust.git] / src / test / run-pass / const-fields-and-indexing.rs
1 // 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
11 const x : [int; 4] = [1,2,3,4];
12 static p : int = x[2];
13 const y : &'static [int] = &[1,2,3,4];
14 static q : int = y[2];
15
16 struct S {a: int, b: int}
17
18 const s : S = S {a: 10, b: 20};
19 static t : int = s.b;
20
21 struct K {a: int, b: int, c: D}
22 struct D { d: int, e: int }
23
24 const k : K = K {a: 10, b: 20, c: D {d: 30, e: 40}};
25 static m : int = k.c.e;
26
27 pub fn main() {
28     println!("{}", p);
29     println!("{}", q);
30     println!("{}", t);
31     assert_eq!(p, 3);
32     assert_eq!(q, 3);
33     assert_eq!(t, 20);
34 }