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

Can't get compile-time-rng/no-rng features to work #161

Closed
bpandreotti opened this issue Aug 23, 2023 · 2 comments
Closed

Can't get compile-time-rng/no-rng features to work #161

bpandreotti opened this issue Aug 23, 2023 · 2 comments

Comments

@bpandreotti
Copy link

For my use case, I need deterministic hash maps/sets, but I can't seem to get the compile-time-rng or no-rng features to work in ahash. My Cargo.toml looks like this:

[package]
name = "determinism-test"
version = "0.1.0"
edition = "2021"

[dependencies]
ahash = { version = "0.8.3", default-features = false, features = ["std", "compile-time-rng"] }

and when I run the following code, the hash value is always different:

fn main() {
    let s = RandomState::default();
    println!("{}", s.hash_one("foo"));
}

The same is true if I use the no-rng feature instead of compile-time-rng, or if I fix the CONST_RANDOM_SEED environment variable.

@domenukk
Copy link

domenukk commented Aug 29, 2023

Try if RandomState::with_seeds(0, 0, 0, 0).build_hasher() does the trick for you?

See #132 for context

@bpandreotti
Copy link
Author

Using RandomState::with_seeds does work, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants