Skip to content

Commit

Permalink
Merge pull request #2450 from ljedrz/feat/cfg_sorted_by
Browse files Browse the repository at this point in the history
Introduce cfg_sorted_by
  • Loading branch information
howardwu authored May 23, 2024
2 parents dbc101b + 5b30ccd commit 9d956dd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions utilities/src/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,19 @@ macro_rules! cfg_sort_by_cached_key {
$self.par_sort_by_cached_key($closure);
}};
}

/// Returns a sorted, by-value iterator for the given IndexMap/IndexSet
#[macro_export]
macro_rules! cfg_sorted_by {
($self: expr, $closure: expr) => {{
#[cfg(feature = "serial")]
{
$self.sorted_by($closure)
}

#[cfg(not(feature = "serial"))]
{
$self.par_sorted_by($closure)
}
}};
}

0 comments on commit 9d956dd

Please sign in to comment.