-
Notifications
You must be signed in to change notification settings - Fork 18
/
mod.rs
110 lines (98 loc) · 2.14 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#[cfg(feature = "parallel")]
pub(crate) use rayon::prelude::*;
/// Choose between iter and par_iter
#[cfg(not(feature = "parallel"))]
#[macro_export]
macro_rules! iter {
($e:expr) => {
$e.iter()
};
}
/// Choose between iter and par_iter
#[cfg(feature = "parallel")]
#[macro_export]
macro_rules! iter {
($e:expr) => {
$e.par_iter()
};
}
/// Choose between iter_mut and par_iter_mut
#[cfg(not(feature = "parallel"))]
#[macro_export]
macro_rules! iter_mut {
($e:expr) => {
$e.iter_mut()
};
}
/// Choose between iter_mut and par_iter_mut
#[cfg(feature = "parallel")]
#[macro_export]
macro_rules! iter_mut {
($e:expr) => {
$e.par_iter_mut()
};
}
/// Choose between into_iter and into_par_iter
#[cfg(not(feature = "parallel"))]
#[macro_export]
macro_rules! into_iter {
($e:expr) => {
$e.into_iter()
};
}
/// Choose between into_iter and into_par_iter
#[cfg(feature = "parallel")]
#[macro_export]
macro_rules! into_iter {
($e:expr) => {
$e.into_par_iter()
};
}
/// Choose between sort_by_key and par_sort_by_key
#[cfg(not(feature = "parallel"))]
#[macro_export]
macro_rules! sort_by_key {
($e:expr, $f:expr) => {
$e.sort_by_key($f)
};
}
/// Choose between sort_by_key and par_sort_by_key
#[cfg(feature = "parallel")]
#[macro_export]
macro_rules! sort_by_key {
($e:expr, $f:expr) => {
$e.par_sort_by_key($f)
};
}
/// Choose between sort_unstable_by_key and par_sort_unstable_by_key
#[cfg(not(feature = "parallel"))]
#[macro_export]
macro_rules! sort_unstable_by {
($e:expr, $f:expr) => {
$e.sort_unstable_by($f)
};
}
/// Choose between sort_by_key and par_sort_by_key
#[cfg(feature = "parallel")]
#[macro_export]
macro_rules! sort_unstable_by {
($e:expr, $f:expr) => {
$e.par_sort_unstable_by($f)
};
}
/// Convert the iterator to par_iter if allowed
#[cfg(not(feature = "parallel"))]
#[macro_export]
macro_rules! bridge {
($e:expr) => {
$e
};
}
/// Convert the iterator to par_iter if allowed
#[cfg(feature = "parallel")]
#[macro_export]
macro_rules! bridge {
($e:expr) => {
$e.par_bridge()
};
}