* Provide better output in flaky tests * feat: add seed parameter to multiple algorithms * Update changelog Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
22 lines
628 B
Rust
22 lines
628 B
Rust
use ::rand::SeedableRng;
|
|
#[cfg(not(feature = "std"))]
|
|
use rand::rngs::SmallRng as RngImpl;
|
|
#[cfg(feature = "std")]
|
|
use rand::rngs::StdRng as RngImpl;
|
|
|
|
pub(crate) fn get_rng_impl(seed: Option<u64>) -> RngImpl {
|
|
match seed {
|
|
Some(seed) => RngImpl::seed_from_u64(seed),
|
|
None => {
|
|
cfg_if::cfg_if! {
|
|
if #[cfg(feature = "std")] {
|
|
use rand::RngCore;
|
|
RngImpl::seed_from_u64(rand::thread_rng().next_u64())
|
|
} else {
|
|
panic!("seed number needed for non-std build");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|