-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
cannot find function backup_entropy
in this scope for wasm target even though source seed always provided
#33
Comments
For 0.8, I'll likely add an |
I downgraded it to 0.5.2 and it worked for me. running in Cloudflare workers with WASM. |
Hi @krolaw , how did you fix this issue? I tried nanorand = {version = "0.7.0", features = ["entropy, wyrand"]} but the compiler emit error |
I reimplemented WyRand that takes a seed. Code is very short, I'll post it there's interest. |
@krolaw Would love to see your code and find out if it can be merged to main. |
It's not really suitable to merge into main. However, it is simple enough to copy to where you want it. pub struct WyRand {
pub seed: u64,
}
const P0: u64 = 0xa076_1d64_78bd_642f;
const P1: u64 = 0xe703_7ed1_a0b4_28db;
impl WyRand {
pub fn rand(&mut self) -> u64 {
self.seed = self.seed.wrapping_add(P0);
let r = u128::from(self.seed) * u128::from(self.seed ^ P1);
((r >> 64) ^ r) as u64
}
pub fn range(&mut self, max: u64) -> u64 {
self.rand() % max
}
} |
Apologies for asking a question by using an issue - I'm new to rust, and I wasn't sure how to deal with this myself.
I am wanting to reliably reproduce/shuffle vast quantities of data in wasm (yew-rs) by way of a seed provided by a server:
I don't think I need an additional source of entropy, since WyRand reproduces the same data for the same seed?
Cargo.toml entry:
Thanks.
The text was updated successfully, but these errors were encountered: