Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: re-export rayon traits implementations #836

Merged
merged 3 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading