//! Implements rng using the xoshiro256++ algorithm use rand::rand_core::{RngCore, SeedableRng}; use rand_xoshiro::Xoshiro256PlusPlus; /// Deterministic pseudo random number generator. #[derive(Debug, Clone, PartialEq, Eq)] pub struct DungeonRng(Xoshiro256PlusPlus); impl SeedableRng for DungeonRng { // Fix to 256 bits. Changing this is a breaking change! type Seed = ::Seed; #[inline] fn from_seed(seed: Self::Seed) -> Self { Self(Xoshiro256PlusPlus::from_seed(seed)) } #[inline] fn seed_from_u64(state: u64) -> Self { Self(Xoshiro256PlusPlus::seed_from_u64(state)) } } impl RngCore for DungeonRng { #[inline] fn next_u32(&mut self) -> u32 { self.0.next_u32() } #[inline] fn next_u64(&mut self) -> u64 { self.0.next_u64() } #[inline] fn fill_bytes(&mut self, dst: &mut [u8]) { self.0.fill_bytes(dst); } }