rust/test/arrays.rs
Scott Olson d3b47c418f WIP: Support array indexing including a get_unchecked test.
Required supporting:
  * Trait method lookup
  * The `offset` intrinsic
  * Fat pointers
  * Unsizing coercions and some raw pointer and integer casts
2016-03-16 23:28:49 -06:00

24 lines
368 B
Rust
Executable File

#![feature(custom_attribute)]
#![allow(dead_code, unused_attributes)]
#[miri_run]
fn empty_array() -> [u16; 0] {
[]
}
#[miri_run]
fn big_array() -> [u16; 5] {
[5, 4, 3, 2, 1]
}
#[miri_run]
fn array_array() -> [[u8; 2]; 3] {
[[5, 4], [3, 2], [1, 0]]
}
#[miri_run]
fn indexing() -> i32 {
let a = [0, 10, 20, 30];
unsafe { *a.get_unchecked(2) }
}