rust/test/vecs.rs

26 lines
421 B
Rust
Raw Normal View History

2016-03-20 21:18:09 -05:00
#![feature(custom_attribute)]
#![allow(dead_code, unused_attributes)]
#[miri_run]
fn make_vec() -> Vec<i32> {
2016-03-21 03:41:07 -05:00
let mut v = Vec::with_capacity(4);
2016-03-20 21:18:09 -05:00
v.push(1);
v.push(2);
v
}
2016-03-21 03:41:22 -05:00
#[miri_run]
fn make_vec_macro() -> Vec<i32> {
vec![1, 2]
}
2016-03-21 04:19:07 -05:00
#[miri_run]
fn make_vec_macro_repeat() -> Vec<u8> {
vec![42; 8]
}
2016-03-21 04:19:07 -05:00
#[miri_run]
2016-03-21 05:12:07 -05:00
fn vec_into_iter() -> i32 {
2016-03-21 04:19:07 -05:00
vec![1, 2, 3, 4].into_iter().fold(0, |x, y| x + y)
}