sysinfo/
utils.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
// Take a look at the license at the top of the repository in the LICENSE file.

cfg_if! {
    if #[cfg(all(
        feature = "multithread",
        not(feature = "unknown-ci"),
        not(all(target_os = "macos", feature = "apple-sandbox")),
    ))] {
        /// Converts the value into a parallel iterator if the `multithread` feature is enabled.
        /// Uses the `rayon::iter::IntoParallelIterator` trait.
        #[cfg(all(
            feature = "multithread",
            not(feature = "unknown-ci"),
            not(all(target_os = "macos", feature = "apple-sandbox")),
        ))]
        #[allow(dead_code)]
        pub(crate) fn into_iter<T>(val: T) -> T::Iter
        where
            T: rayon::iter::IntoParallelIterator,
        {
            val.into_par_iter()
        }

        // /// Converts the value into a parallel mutable iterator if the `multithread` feature is
        // /// enabled. Uses the `rayon::iter::IntoParallelRefMutIterator` trait.
        // #[cfg(feature = "component")]
        // pub(crate) fn into_iter_mut<'a, T>(
        //     val: &'a mut T,
        // ) -> <T as rayon::iter::IntoParallelRefMutIterator<'a>>::Iter
        // where
        //     T: rayon::iter::IntoParallelRefMutIterator<'a> + ?Sized,
        // {
        //     val.par_iter_mut()
        // }
    } else {
        /// Converts the value into a sequential iterator if the `multithread` feature is disabled.
        /// Uses the `std::iter::IntoIterator` trait.
        #[allow(dead_code)]
        pub(crate) fn into_iter<T>(val: T) -> T::IntoIter
        where
            T: IntoIterator,
        {
            val.into_iter()
        }

        // In the multithreaded version of `into_iter_mut` above, the `&mut` on the argument is
        // indicating the parallel iterator is an exclusive reference. In the non-multithreaded
        // case, the `&mut` is already part of `T` and specifying it will result in the argument
        // being `&mut &mut T`.

        // /// Converts the value into a sequential mutable iterator if the `multithread` feature is
        // /// disabled. Uses the `std::iter::IntoIterator` trait.
        // #[cfg(feature = "component")]
        // pub(crate) fn into_iter_mut<T>(val: T) -> T::IntoIter
        // where
        //     T: IntoIterator,
        // {
        //     val.into_iter()
        // }
    }
}