mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
remove OsRng from sample/src/source.rs
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
use rand_chacha::ChaCha8Rng;
|
use rand_chacha::ChaCha8Rng;
|
||||||
use rand_chacha::rand_core::SeedableRng;
|
use rand_chacha::rand_core::SeedableRng;
|
||||||
use rand_core::{OsRng, RngCore, TryRngCore};
|
use rand_core::RngCore;
|
||||||
|
|
||||||
const MAXF64: f64 = 9007199254740992.0;
|
const MAXF64: f64 = 9007199254740992.0;
|
||||||
|
|
||||||
@@ -8,12 +8,6 @@ pub struct Source {
|
|||||||
source: ChaCha8Rng,
|
source: ChaCha8Rng,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_seed() -> [u8; 32] {
|
|
||||||
let mut seed = [0u8; 32];
|
|
||||||
OsRng.try_fill_bytes(&mut seed).unwrap();
|
|
||||||
seed
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Source {
|
impl Source {
|
||||||
pub fn new(seed: [u8; 32]) -> Source {
|
pub fn new(seed: [u8; 32]) -> Source {
|
||||||
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 {
|
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)]
|
#[inline(always)]
|
||||||
|
|||||||
Reference in New Issue
Block a user