]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2014 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 | ||
c34b1796 | 11 | |
1a4d82fc JJ |
12 | #![allow(unknown_features)] |
13 | #![feature(box_syntax)] | |
14 | ||
15 | pub fn main() { | |
16 | // Tests for indexing into box/& [T; n] | |
c34b1796 AL |
17 | let x: [isize; 3] = [1, 2, 3]; |
18 | let mut x: Box<[isize; 3]> = box x; | |
1a4d82fc JJ |
19 | assert!(x[0] == 1); |
20 | assert!(x[1] == 2); | |
21 | assert!(x[2] == 3); | |
22 | x[1] = 45; | |
23 | assert!(x[0] == 1); | |
24 | assert!(x[1] == 45); | |
25 | assert!(x[2] == 3); | |
26 | ||
c34b1796 AL |
27 | let mut x: [isize; 3] = [1, 2, 3]; |
28 | let x: &mut [isize; 3] = &mut x; | |
1a4d82fc JJ |
29 | assert!(x[0] == 1); |
30 | assert!(x[1] == 2); | |
31 | assert!(x[2] == 3); | |
32 | x[1] = 45; | |
33 | assert!(x[0] == 1); | |
34 | assert!(x[1] == 45); | |
35 | assert!(x[2] == 3); | |
36 | } |