Skip to content

Commit

Permalink
feat: re-export rayon traits implementations (#836)
Browse files Browse the repository at this point in the history
* re-export rayon traits implementations

* fix

* merge imports
  • Loading branch information
lightsing authored Jan 3, 2025
1 parent 4c97179 commit bbfab8c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ pretty_assertions = "1.4"
proptest = "1"
proptest-derive = "0.5"
rand = { version = "0.8", default-features = false }
rayon = { version = "1.2", default-features = false }
ruint = { version = "1.12.3", default-features = false, features = ["alloc"] }
ruint-macro = { version = "1", default-features = false }
winnow = { version = "0.6", default-features = false, features = ["alloc"] }
5 changes: 4 additions & 1 deletion crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ getrandom = { workspace = true, optional = true }
# rand
rand = { workspace = true, optional = true, features = ["getrandom"] }

# rayon
rayon = { workspace = true, optional = true }

# k256
k256 = { workspace = true, optional = true, features = ["ecdsa"] }

Expand Down Expand Up @@ -132,7 +135,7 @@ map-fxhash = ["map", "dep:rustc-hash"]
getrandom = ["dep:getrandom"]
k256 = ["dep:k256"]
rand = ["dep:rand", "getrandom", "ruint/rand", "rustc-hash?/rand"]
rayon = ["hashbrown?/rayon", "indexmap?/rayon"]
rayon = ["dep:rayon", "hashbrown?/rayon", "indexmap?/rayon"]
rlp = ["dep:alloy-rlp", "ruint/alloy-rlp"]
serde = [
"dep:serde",
Expand Down
25 changes: 25 additions & 0 deletions crates/primitives/src/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,31 @@ cfg_if! {
}
}

/// This module contains the rayon parallel iterator types for hash maps (HashMap<K, V>).
/// You will rarely need to interact with it directly unless you have need to name one
/// of the iterator types.
#[cfg(feature = "rayon")]
pub mod rayon {
use super::*;

cfg_if! {
if #[cfg(any(feature = "map-hashbrown", not(feature = "std")))] {
pub use hashbrown::hash_map::rayon::{
IntoParIter as IntoIter,
ParDrain as Drain,
ParIter as Iter,
ParIterMut as IterMut,
ParKeys as Keys,
ParValues as Values,
ParValuesMut as ValuesMut
};
use ::rayon as _;
} else {
pub use ::rayon::collections::hash_map::*;
}
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit bbfab8c

Please sign in to comment.