1use rayon::prelude::*;
2
3#[test]
4fn drain_vec_yielded() {
5 let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
6
7 let yielded = vec_org.par_drain(0..5).collect::<Vec<_>>();
8
9 assert_eq!(&yielded, &[0, 1, 2, 3, 4]);
10 assert_eq!(&vec_org, &[5, 6, 7, 8, 9]);
11}
12
13#[test]
14fn drain_vec_dropped() {
15 let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
16
17 let yielded = vec_org.par_drain(0..5);
18
19 drop(yielded);
20 assert_eq!(&vec_org, &[5, 6, 7, 8, 9]);
21}
22
23#[test]
24fn drain_vec_empty_range_yielded() {
25 let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
26
27 let yielded = vec_org.par_drain(5..5).collect::<Vec<_>>();
28
29 assert_eq!(&yielded, &[]);
30 assert_eq!(&vec_org, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
31}
32
33#[test]
34fn drain_vec_empty_range_dropped() {
35 let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
36
37 let yielded = vec_org.par_drain(5..5);
38
39 drop(yielded);
40 assert_eq!(&vec_org, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
41}
42