diff options
Diffstat (limited to 'src/test/run-pass/array-slice-vec/vec-dst.rs')
| -rw-r--r-- | src/test/run-pass/array-slice-vec/vec-dst.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/run-pass/array-slice-vec/vec-dst.rs b/src/test/run-pass/array-slice-vec/vec-dst.rs new file mode 100644 index 00000000000..6421b69d22e --- /dev/null +++ b/src/test/run-pass/array-slice-vec/vec-dst.rs @@ -0,0 +1,36 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(box_syntax)] + +pub fn main() { + // Tests for indexing into box/& [T; n] + let x: [isize; 3] = [1, 2, 3]; + let mut x: Box<[isize; 3]> = box x; + assert_eq!(x[0], 1); + assert_eq!(x[1], 2); + assert_eq!(x[2], 3); + x[1] = 45; + assert_eq!(x[0], 1); + assert_eq!(x[1], 45); + assert_eq!(x[2], 3); + + let mut x: [isize; 3] = [1, 2, 3]; + let x: &mut [isize; 3] = &mut x; + assert_eq!(x[0], 1); + assert_eq!(x[1], 2); + assert_eq!(x[2], 3); + x[1] = 45; + assert_eq!(x[0], 1); + assert_eq!(x[1], 45); + assert_eq!(x[2], 3); +} |
