-
Notifications
You must be signed in to change notification settings - Fork 491
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix rayon issues * Fix typos * Fix for_each no std * Fix clippy
- Loading branch information
Showing
7 changed files
with
119 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,90 @@ | ||
/// Macro for running a function in parallel. | ||
#[cfg(feature = "rayon")] | ||
#[macro_export(local_inner_macros)] | ||
macro_rules! run_par { | ||
( | ||
$func:expr | ||
) => {{ | ||
#[cfg(feature = "rayon")] | ||
use rayon::prelude::*; | ||
use $crate::rayon::prelude::*; | ||
|
||
#[cfg(feature = "rayon")] | ||
#[allow(clippy::redundant_closure_call)] | ||
let output = rayon::scope(|_| $func()); | ||
$crate::rayon::scope(|_| $func()) | ||
}}; | ||
} | ||
|
||
#[cfg(not(feature = "rayon"))] | ||
let output = $func(); | ||
/// Macro for running a function in parallel. | ||
#[cfg(not(feature = "rayon"))] | ||
#[macro_export(local_inner_macros)] | ||
macro_rules! run_par { | ||
( | ||
$func:expr | ||
) => {{ | ||
$func() | ||
}}; | ||
} | ||
|
||
output | ||
/// Macro for iterating in parallel. | ||
#[cfg(not(feature = "rayon"))] | ||
#[macro_export(local_inner_macros)] | ||
macro_rules! iter_par { | ||
( | ||
$iter:expr | ||
) => {{ | ||
$iter | ||
}}; | ||
} | ||
|
||
/// Macro for iterating in parallel. | ||
#[cfg(feature = "rayon")] | ||
#[macro_export(local_inner_macros)] | ||
macro_rules! iter_par { | ||
( | ||
$iter:expr | ||
) => {{ | ||
#[cfg(feature = "rayon")] | ||
let output = $iter.into_par_iter(); | ||
$iter.into_par_iter() | ||
}}; | ||
} | ||
|
||
#[cfg(not(feature = "rayon"))] | ||
let output = $iter; | ||
/// Macro for iterating in parallel. | ||
#[cfg(feature = "rayon")] | ||
#[macro_export(local_inner_macros)] | ||
macro_rules! iter_slice_par { | ||
( | ||
$slice:expr | ||
) => {{ | ||
$slice.into_par_iter() | ||
}}; | ||
} | ||
|
||
output | ||
/// Macro for iterating in parallel. | ||
#[cfg(not(feature = "rayon"))] | ||
#[macro_export(local_inner_macros)] | ||
macro_rules! iter_slice_par { | ||
( | ||
$slice:expr | ||
) => {{ | ||
$slice.iter() | ||
}}; | ||
} | ||
|
||
/// Macro for iterating over a range in parallel. | ||
#[cfg(feature = "rayon")] | ||
#[macro_export(local_inner_macros)] | ||
macro_rules! iter_range_par { | ||
( | ||
$start:expr, $end:expr | ||
) => {{ | ||
#[cfg(feature = "rayon")] | ||
let output = ($start..$end).into_par_iter(); | ||
|
||
#[cfg(not(feature = "rayon"))] | ||
let output = ($start..$end); | ||
($start..$end).into_par_iter() | ||
}}; | ||
} | ||
|
||
output | ||
/// Macro for iterating over a range in parallel. | ||
#[cfg(not(feature = "rayon"))] | ||
#[macro_export(local_inner_macros)] | ||
macro_rules! iter_range_par { | ||
( | ||
$start:expr, $end:expr | ||
) => {{ | ||
($start..$end) | ||
}}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters