Skip to content

Commit

Permalink
Remove usage of the compile-time-rng crate feature from the ahash
Browse files Browse the repository at this point in the history
… dependency (#1023)

* remove compile-time-rng crate feature usage

* apply rustfmt
  • Loading branch information
Robbepop committed May 9, 2024
1 parent 30ca773 commit 302a24f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/collections/Cargo.toml
Expand Up @@ -16,7 +16,7 @@ exclude.workspace = true
[dependencies]
hashbrown = { version = "0.14", default-features = false, features = ["ahash", "inline-more"] }
string-interner = { version = "0.17", default-features = false, features = ["inline-more", "backends"] }
ahash = { version = "0.8.11", default-features = false, features = ["compile-time-rng"] }
ahash = { version = "0.8.11", default-features = false }

[features]
default = ["std"]
Expand Down
11 changes: 10 additions & 1 deletion crates/collections/src/hash.rs
Expand Up @@ -96,12 +96,21 @@ use std::collections::hash_map::RandomState as RandomStateImpl;

// When the `std` feature is NOT active then rely on `ahash::RandomState`
// which relies on ASLR by default for randomness.
#[derive(Default, Clone, Debug)]
#[derive(Clone, Debug)]
#[cfg(not(feature = "std"))]
struct RandomStateImpl {
state: ahash::RandomState,
}

#[cfg(not(feature = "std"))]
impl Default for RandomStateImpl {
fn default() -> Self {
Self {
state: ahash::RandomState::new(),
}
}
}

#[cfg(not(feature = "std"))]
impl BuildHasher for RandomStateImpl {
type Hasher = ahash::AHasher;
Expand Down

0 comments on commit 302a24f

Please sign in to comment.