sysinfo/
utils.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3/// Converts the value into a parallel iterator (if the multi-thread feature is enabled).
4/// Uses the `rayon::iter::IntoParallelIterator` trait.
5#[cfg(all(
6    all(
7        any(
8            target_os = "linux",
9            target_os = "android",
10            target_os = "macos",
11            target_os = "windows",
12            target_os = "freebsd",
13        ),
14        feature = "multithread"
15    ),
16    not(all(target_os = "macos", feature = "apple-sandbox")),
17    not(feature = "unknown-ci")
18))]
19pub(crate) fn into_iter<T>(val: T) -> T::Iter
20where
21    T: rayon::iter::IntoParallelIterator,
22{
23    val.into_par_iter()
24}
25
26/// Converts the value into a sequential iterator (if the multithread feature is disabled).
27/// Uses the `std::iter::IntoIterator` trait.
28#[cfg(all(
29    all(
30        any(
31            target_os = "linux",
32            target_os = "android",
33            target_os = "macos",
34            target_os = "windows",
35            target_os = "freebsd",
36        ),
37        not(feature = "multithread")
38    ),
39    not(feature = "unknown-ci"),
40    not(all(target_os = "macos", feature = "apple-sandbox"))
41))]
42pub(crate) fn into_iter<T>(val: T) -> T::IntoIter
43where
44    T: IntoIterator,
45{
46    val.into_iter()
47}