1 use oorandom::Rand64;
2 use std::cell::RefCell;
3 use std::time::{SystemTime, UNIX_EPOCH};
4 
5 pub type Rng = Rand64;
6 
7 thread_local! {
8     static SEED_RAND: RefCell<Rand64> = RefCell::new(Rand64::new(
9         SystemTime::now().duration_since(UNIX_EPOCH)
10             .expect("Time went backwards")
11             .as_millis()
12     ));
13 }
14 
new_rng() -> Rng15 pub fn new_rng() -> Rng {
16     SEED_RAND.with(|r| {
17         let mut r = r.borrow_mut();
18         let seed = ((r.rand_u64() as u128) << 64) | (r.rand_u64() as u128);
19         Rand64::new(seed)
20     })
21 }
22