use {
core::num::NonZeroU16,
oorandom::Rand32,
};
pub struct RandomNumberGenerator(Rand32);
impl Default for RandomNumberGenerator
{
#[inline]
fn default() -> Self
{
#[allow(clippy::unreadable_literal)]
const STATE: (u64, u64) = (10116158231463745938, 2885390081777926815);
Self(Rand32::from_state(STATE))
}
}
impl super::NumberGenerator for RandomNumberGenerator
{
#[inline]
fn rand_upto(
&mut self,
exclusive_end: NonZeroU16,
) -> u16
{
#![allow(clippy::as_conversions, clippy::cast_possible_truncation)]
let exclusive_end: u32 = exclusive_end.get().into();
self.0.rand_range(0 .. exclusive_end) as u16
}
}