]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/vec-dst.rs
rollup merge of #20086: shepmaster/random-typo
[rust.git] / src / test / run-pass / vec-dst.rs
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
11 pub fn main() {
12     // Tests for indexing into box/& [T; n]
13     let x: [int; 3] = [1, 2, 3];
14     let mut x: Box<[int; 3]> = box x;
15     assert!(x[0] == 1);
16     assert!(x[1] == 2);
17     assert!(x[2] == 3);
18     x[1] = 45;
19     assert!(x[0] == 1);
20     assert!(x[1] == 45);
21     assert!(x[2] == 3);
22
23     let mut x: [int; 3] = [1, 2, 3];
24     let x: &mut [int; 3] = &mut x;
25     assert!(x[0] == 1);
26     assert!(x[1] == 2);
27     assert!(x[2] == 3);
28     x[1] = 45;
29     assert!(x[0] == 1);
30     assert!(x[1] == 45);
31     assert!(x[2] == 3);
32 }