From 2a5e0e7dc30f3b62b02371c68e7b9f52ba93d0ed Mon Sep 17 00:00:00 2001 From: Janmajaya Mall Date: Fri, 4 Jul 2025 17:56:30 +0530 Subject: [PATCH] remove `OsRng` from `sample/src/source.rs` --- sampling/src/source.rs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/sampling/src/source.rs b/sampling/src/source.rs index c356163..fe5f641 100644 --- a/sampling/src/source.rs +++ b/sampling/src/source.rs @@ -1,6 +1,6 @@ use rand_chacha::ChaCha8Rng; use rand_chacha::rand_core::SeedableRng; -use rand_core::{OsRng, RngCore, TryRngCore}; +use rand_core::RngCore; const MAXF64: f64 = 9007199254740992.0; @@ -8,12 +8,6 @@ pub struct Source { source: ChaCha8Rng, } -pub fn new_seed() -> [u8; 32] { - let mut seed = [0u8; 32]; - OsRng.try_fill_bytes(&mut seed).unwrap(); - seed -} - impl Source { pub fn new(seed: [u8; 32]) -> Source { Source { @@ -21,14 +15,11 @@ impl Source { } } - pub fn new_seed(&mut self) -> [u8; 32] { - let mut seed: [u8; 32] = [0u8; 32]; - self.source.fill_bytes(&mut seed); - seed - } - pub fn branch(&mut self) -> Self { - Source::new(self.new_seed()) + let mut seed = [0; 32]; + self.source.fill_bytes(&mut seed); + + Source::new(seed) } #[inline(always)]