]> git.proxmox.com Git - rustc.git/blob - src/vendor/rayon/src/iter/noop.rs
New upstream version 1.25.0+dfsg1
[rustc.git] / src / vendor / rayon / src / iter / noop.rs
1 use super::plumbing::*;
2
3 pub struct NoopConsumer;
4
5 impl NoopConsumer {
6 pub fn new() -> Self {
7 NoopConsumer
8 }
9 }
10
11 impl<T> Consumer<T> for NoopConsumer {
12 type Folder = NoopConsumer;
13 type Reducer = NoopReducer;
14 type Result = ();
15
16 fn split_at(self, _index: usize) -> (Self, Self, NoopReducer) {
17 (NoopConsumer, NoopConsumer, NoopReducer)
18 }
19
20 fn into_folder(self) -> Self {
21 self
22 }
23
24 fn full(&self) -> bool {
25 false
26 }
27 }
28
29 impl<T> Folder<T> for NoopConsumer {
30 type Result = ();
31
32 fn consume(self, _item: T) -> Self {
33 self
34 }
35
36 fn consume_iter<I>(self, iter: I) -> Self where I: IntoIterator<Item=T> {
37 iter.into_iter().fold((), |_, _| ());
38 self
39 }
40
41 fn complete(self) {}
42
43 fn full(&self) -> bool {
44 false
45 }
46 }
47
48 impl<T> UnindexedConsumer<T> for NoopConsumer {
49 fn split_off_left(&self) -> Self {
50 NoopConsumer
51 }
52
53 fn to_reducer(&self) -> NoopReducer {
54 NoopReducer
55 }
56 }
57
58 pub struct NoopReducer;
59
60 impl Reducer<()> for NoopReducer {
61 fn reduce(self, _left: (), _right: ()) {}
62 }