pub struct SIDRng { /* private fields */ }Expand description
Random number generator using the SID oscillator
Implements the rand::RngCore
trait and can thus be used with Rusts rand crate.
For single random bytes, it is likely more efficient to use random_byte()
from the SID chip directly, as the smallest integer implemented in RngCore is u32,
i.e. four random bytes.
§Examples
use mos_hardware::{c64, sid};
use rand::seq::SliceRandom;
let mut rng = sid::SIDRng::new(c64::sid());
let value = [11, 23].choose(&mut rng).unwrap(); // 11 or 23Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SIDRng
impl !RefUnwindSafe for SIDRng
impl !Send for SIDRng
impl !Sync for SIDRng
impl Unpin for SIDRng
impl !UnwindSafe for SIDRng
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more