]> git.lizzy.rs Git - rust.git/blob - tests/run-pass/vecs.rs
63757947b0a1f6e0c8fdde66d861bbb3c300f841
[rust.git] / tests / run-pass / vecs.rs
1 #![crate_type = "lib"]
2 #![feature(custom_attribute)]
3 #![allow(dead_code, unused_attributes)]
4
5 #[miri_run]
6 fn make_vec() -> Vec<u8> {
7     let mut v = Vec::with_capacity(4);
8     v.push(1);
9     v.push(2);
10     v
11 }
12
13 #[miri_run]
14 fn make_vec_macro() -> Vec<u8> {
15     vec![1, 2]
16 }
17
18 #[miri_run]
19 fn make_vec_macro_repeat() -> Vec<u8> {
20     vec![42; 5]
21 }
22
23 #[miri_run]
24 fn vec_into_iter() -> u8 {
25     vec![1, 2, 3, 4]
26         .into_iter()
27         .map(|x| x * x)
28         .fold(0, |x, y| x + y)
29 }
30
31 #[miri_run]
32 fn vec_reallocate() -> Vec<u8> {
33     let mut v = vec![1, 2];
34     v.push(3);
35     v.push(4);
36     v.push(5);
37     v
38 }