1use rayon::prelude::*;
2use std::fmt::Debug;
3
4fn check<I>(iter: I)
5where
6 I: ParallelIterator + Debug,
7{
8 println!("{:?}", iter);
9}
10
11#[test]
12fn debug_binary_heap() {
13 use std::collections::BinaryHeap;
14 let mut heap: BinaryHeap<_> = (0..10).collect();
15 check(heap.par_iter());
16 check(heap.par_drain());
17 check(heap.into_par_iter());
18}
19
20#[test]
21fn debug_btree_map() {
22 use std::collections::BTreeMap;
23 let mut map: BTreeMap<_, _> = (0..10).enumerate().collect();
24 check(map.par_iter());
25 check(map.par_iter_mut());
26 check(map.into_par_iter());
27}
28
29#[test]
30fn debug_btree_set() {
31 use std::collections::BTreeSet;
32 let set: BTreeSet<_> = (0..10).collect();
33 check(set.par_iter());
34 check(set.into_par_iter());
35}
36
37#[test]
38fn debug_hash_map() {
39 use std::collections::HashMap;
40 let mut map: HashMap<_, _> = (0..10).enumerate().collect();
41 check(map.par_iter());
42 check(map.par_iter_mut());
43 check(map.par_drain());
44 check(map.into_par_iter());
45}
46
47#[test]
48fn debug_hash_set() {
49 use std::collections::HashSet;
50 let mut set: HashSet<_> = (0..10).collect();
51 check(set.par_iter());
52 check(set.par_drain());
53 check(set.into_par_iter());
54}
55
56#[test]
57fn debug_linked_list() {
58 use std::collections::LinkedList;
59 let mut list: LinkedList<_> = (0..10).collect();
60 check(list.par_iter());
61 check(list.par_iter_mut());
62 check(list.into_par_iter());
63}
64
65#[test]
66fn debug_vec_deque() {
67 use std::collections::VecDeque;
68 let mut deque: VecDeque<_> = (0..10).collect();
69 check(deque.par_iter());
70 check(deque.par_iter_mut());
71 check(deque.par_drain(..));
72 check(deque.into_par_iter());
73}
74
75#[test]
76fn debug_option() {
77 let mut option = Some(0);
78 check(option.par_iter());
79 check(option.par_iter_mut());
80 check(option.into_par_iter());
81}
82
83#[test]
84fn debug_result() {
85 let mut result = Ok::<_, ()>(0);
86 check(result.par_iter());
87 check(result.par_iter_mut());
88 check(result.into_par_iter());
89}
90
91#[test]
92fn debug_range() {
93 check((0..10).into_par_iter());
94}
95
96#[test]
97fn debug_range_inclusive() {
98 check((0..=10).into_par_iter());
99}
100
101#[test]
102fn debug_str() {
103 let s = "a b c d\ne f g";
104 check(s.par_chars());
105 check(s.par_lines());
106 check(s.par_split('\n'));
107 check(s.par_split_terminator('\n'));
108 check(s.par_split_whitespace());
109}
110
111#[test]
112fn debug_string() {
113 let mut s = "a b c d\ne f g".to_string();
114 s.par_drain(..);
115}
116
117#[test]
118fn debug_vec() {
119 let mut v: Vec<_> = (0..10).collect();
120 check(v.par_iter());
121 check(v.par_iter_mut());
122 check(v.par_chunks(42));
123 check(v.par_chunks_exact(42));
124 check(v.par_chunks_mut(42));
125 check(v.par_chunks_exact_mut(42));
126 check(v.par_rchunks(42));
127 check(v.par_rchunks_exact(42));
128 check(v.par_rchunks_mut(42));
129 check(v.par_rchunks_exact_mut(42));
130 check(v.par_windows(42));
131 check(v.par_split(|x| x % 3 == 0));
132 check(v.par_split_mut(|x| x % 3 == 0));
133 check(v.par_drain(..));
134 check(v.into_par_iter());
135}
136
137#[test]
138fn debug_array() {
139 let a = [0i32; 10];
140 check(a.into_par_iter());
141}
142
143#[test]
144fn debug_adaptors() {
145 let v: Vec<_> = (0..10).collect();
146 check(v.par_iter().chain(&v));
147 check(v.par_iter().cloned());
148 check(v.par_iter().copied());
149 check(v.par_iter().enumerate());
150 check(v.par_iter().filter(|_| true));
151 check(v.par_iter().filter_map(Some));
152 check(v.par_iter().flat_map(Some));
153 check(v.par_iter().flat_map_iter(Some));
154 check(v.par_iter().map(Some).flatten());
155 check(v.par_iter().map(Some).flatten_iter());
156 check(v.par_iter().fold(|| 0, |x, _| x));
157 check(v.par_iter().fold_with(0, |x, _| x));
158 check(v.par_iter().fold_chunks(3, || 0, |x, _| x));
159 check(v.par_iter().fold_chunks_with(3, 0, |x, _| x));
160 check(v.par_iter().try_fold(|| 0, |x, _| Some(x)));
161 check(v.par_iter().try_fold_with(0, |x, _| Some(x)));
162 check(v.par_iter().inspect(|_| ()));
163 check(v.par_iter().update(|_| ()));
164 check(v.par_iter().interleave(&v));
165 check(v.par_iter().interleave_shortest(&v));
166 check(v.par_iter().intersperse(&-1));
167 check(v.par_iter().chunks(3));
168 check(v.par_iter().map(|x| x));
169 check(v.par_iter().map_with(0, |_, x| x));
170 check(v.par_iter().map_init(|| 0, |_, x| x));
171 check(v.par_iter().panic_fuse());
172 check(v.par_iter().positions(|_| true));
173 check(v.par_iter().rev());
174 check(v.par_iter().skip(1));
175 check(v.par_iter().skip_any(1));
176 check(v.par_iter().skip_any_while(|_| false));
177 check(v.par_iter().take(1));
178 check(v.par_iter().take_any(1));
179 check(v.par_iter().take_any_while(|_| true));
180 check(v.par_iter().map(Some).while_some());
181 check(v.par_iter().with_max_len(1));
182 check(v.par_iter().with_min_len(1));
183 check(v.par_iter().zip(&v));
184 check(v.par_iter().zip_eq(&v));
185 check(v.par_iter().step_by(2));
186}
187
188#[test]
189fn debug_empty() {
190 check(rayon::iter::empty::<i32>());
191}
192
193#[test]
194fn debug_once() {
195 check(rayon::iter::once(10));
196}
197
198#[test]
199fn debug_repeat() {
200 let x: Option<i32> = None;
201 check(rayon::iter::repeat(x));
202 check(rayon::iter::repeatn(x, 10));
203}
204
205#[test]
206fn debug_splitter() {
207 check(rayon::iter::split(0..10, |x| (x, None)));
208}
209
210#[test]
211fn debug_multizip() {
212 let v: &Vec<_> = &(0..10).collect();
213 check((v,).into_par_iter());
214 check((v, v).into_par_iter());
215 check((v, v, v).into_par_iter());
216 check((v, v, v, v).into_par_iter());
217 check((v, v, v, v, v).into_par_iter());
218 check((v, v, v, v, v, v).into_par_iter());
219 check((v, v, v, v, v, v, v).into_par_iter());
220 check((v, v, v, v, v, v, v, v).into_par_iter());
221 check((v, v, v, v, v, v, v, v, v).into_par_iter());
222 check((v, v, v, v, v, v, v, v, v, v).into_par_iter());
223 check((v, v, v, v, v, v, v, v, v, v, v).into_par_iter());
224 check((v, v, v, v, v, v, v, v, v, v, v, v).into_par_iter());
225}
226