1use gut::prelude::*;
3
4pub use rand::prelude::*;
5
6pub fn rng_with_seed(seed: impl Into<Option<u64>>) -> StdRng {
8 let seed = seed.into().unwrap_or_else(|| {
9 let value = gut::utils::unix_timestamp();
10 info!("gosh: the random process can be repeated with seed {value}");
11 value
12 });
13 StdRng::seed_from_u64(seed)
14}
15
16#[cfg(test)]
17mod test {
18 #[test]
19 fn test_rng() {
20 use crate::random::*;
21
22 let mut rng = rng_with_seed(None);
23 rng.gen::<i32>();
24 assert_eq!(rng.gen_range(0..1), 0);
25 }
26}
27