diff --git a/Cargo.toml b/Cargo.toml index dbe1cf3..7155cac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,10 +18,10 @@ exclude = ["/.*"] default = ["std"] alloc = [] std = ["alloc"] -js = ["std", "getrandom"] +js = ["std", "getrandom/js"] -[target.'cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), target_os = "unknown"))'.dependencies] -getrandom = { version = "0.2", features = ["js"], optional = true } +[dependencies] +getrandom = "0.2" [target.'cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), target_os = "unknown"))'.dev-dependencies] wasm-bindgen-test = "0.3" diff --git a/src/global_rng.rs b/src/global_rng.rs index 2f6d37e..3bd86bc 100644 --- a/src/global_rng.rs +++ b/src/global_rng.rs @@ -181,26 +181,10 @@ pub fn choose_multiple(source: T, amount: usize) -> Vec { } #[cfg(not(all( - any(target_arch = "wasm32", target_arch = "wasm64"), - target_os = "unknown" -)))] -fn random_seed() -> Option { - use std::collections::hash_map::DefaultHasher; - use std::hash::{Hash, Hasher}; - use std::thread; - use std::time::Instant; - - let mut hasher = DefaultHasher::new(); - Instant::now().hash(&mut hasher); - thread::current().id().hash(&mut hasher); - Some(hasher.finish()) -} - -#[cfg(all( any(target_arch = "wasm32", target_arch = "wasm64"), target_os = "unknown", - feature = "js" -))] + not(feature = "js") +)))] fn random_seed() -> Option { // TODO(notgull): Failures should be logged somewhere. let mut seed = [0u8; 8];