sysinfo/
utils.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3cfg_if! {
4    if #[cfg(all(
5        feature = "multithread",
6        not(feature = "unknown-ci"),
7        not(all(target_os = "macos", feature = "apple-sandbox")),
8    ))] {
9        /// Converts the value into a parallel iterator if the `multithread` feature is enabled.
10        /// Uses the `rayon::iter::IntoParallelIterator` trait.
11        #[cfg(all(
12            feature = "multithread",
13            not(feature = "unknown-ci"),
14            not(all(target_os = "macos", feature = "apple-sandbox")),
15        ))]
16        #[allow(dead_code)]
17        pub(crate) fn into_iter<T>(val: T) -> T::Iter
18        where
19            T: rayon::iter::IntoParallelIterator,
20        {
21            val.into_par_iter()
22        }
23
24        // /// Converts the value into a parallel mutable iterator if the `multithread` feature is
25        // /// enabled. Uses the `rayon::iter::IntoParallelRefMutIterator` trait.
26        // #[cfg(feature = "component")]
27        // pub(crate) fn into_iter_mut<'a, T>(
28        //     val: &'a mut T,
29        // ) -> <T as rayon::iter::IntoParallelRefMutIterator<'a>>::Iter
30        // where
31        //     T: rayon::iter::IntoParallelRefMutIterator<'a> + ?Sized,
32        // {
33        //     val.par_iter_mut()
34        // }
35    } else {
36        /// Converts the value into a sequential iterator if the `multithread` feature is disabled.
37        /// Uses the `std::iter::IntoIterator` trait.
38        #[allow(dead_code)]
39        pub(crate) fn into_iter<T>(val: T) -> T::IntoIter
40        where
41            T: IntoIterator,
42        {
43            val.into_iter()
44        }
45
46        // In the multithreaded version of `into_iter_mut` above, the `&mut` on the argument is
47        // indicating the parallel iterator is an exclusive reference. In the non-multithreaded
48        // case, the `&mut` is already part of `T` and specifying it will result in the argument
49        // being `&mut &mut T`.
50
51        // /// Converts the value into a sequential mutable iterator if the `multithread` feature is
52        // /// disabled. Uses the `std::iter::IntoIterator` trait.
53        // #[cfg(feature = "component")]
54        // pub(crate) fn into_iter_mut<T>(val: T) -> T::IntoIter
55        // where
56        //     T: IntoIterator,
57        // {
58        //     val.into_iter()
59        // }
60    }
61}