forked from getzola/zola
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathno_rayon.rs
48 lines (44 loc) · 1.31 KB
/
no_rayon.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
pub mod prelude {
pub use super::{NoRayonAHashMap, NoRayonHashMap, NoRayonSlice, NoRayonSliceMut};
}
pub trait NoRayonSlice<T> {
fn par_iter(&self) -> core::slice::Iter<'_, T>;
}
impl<T> NoRayonSlice<T> for [T] {
fn par_iter(&self) -> core::slice::Iter<'_, T> {
self.iter()
}
}
pub trait NoRayonSliceMut<T> {
fn par_iter_mut(&mut self) -> core::slice::IterMut<'_, T>;
fn par_sort_unstable_by<F>(&mut self, compare: F)
where
F: Fn(&T, &T) -> std::cmp::Ordering;
}
impl<T> NoRayonSliceMut<T> for [T] {
fn par_iter_mut(&mut self) -> core::slice::IterMut<'_, T> {
self.iter_mut()
}
fn par_sort_unstable_by<F>(&mut self, compare: F)
where
F: Fn(&T, &T) -> std::cmp::Ordering,
{
self.sort_unstable_by(compare)
}
}
pub trait NoRayonHashMap<K, V> {
fn par_iter(&self) -> std::collections::hash_map::Iter<'_, K, V>;
}
impl<K, V> NoRayonHashMap<K, V> for std::collections::HashMap<K, V> {
fn par_iter(&self) -> std::collections::hash_map::Iter<'_, K, V> {
self.iter()
}
}
pub trait NoRayonAHashMap<K, V> {
fn par_iter(&self) -> std::collections::hash_map::Iter<'_, K, V>;
}
impl<K, V> NoRayonAHashMap<K, V> for ahash::AHashMap<K, V> {
fn par_iter(&self) -> std::collections::hash_map::Iter<'_, K, V> {
self.iter()
}
}