[][src]Struct picorand::RNG

pub struct RNG<R: PicoRandRNG = WyRand, T = u64> { /* fields omitted */ }

An abstraction over a PRNG with a specific seed.

Implementations

impl<R: PicoRandRNG, T> RNG<R, T> where
    <R as PicoRandRNG>::Output: TryInto<T>, 
[src]

pub fn new(seed: R::Input) -> Self[src]

Create a new RNG instance using a specific PRNG and a specific seed.

pub fn generate_range(&mut self, min: usize, max: usize) -> T where
    <R as PicoRandRNG>::Output: Into<u128>,
    T: Default + TryFrom<u128>, 
[src]

Generate a number in the specified range.

Example

use picorand::{WyRand, RNG};
let mut rng = RNG::<WyRand, u8>::new(0xDEADBEEF);
let generated = rng.generate_range(0xC0, 0xDE);
assert!(generated >= 0xC0 || generated <= 0xDE);

Trait Implementations

impl<R: PicoRandRNG> PicoRandGenerate<R, u16> for RNG<R, u16> where
    <R as PicoRandRNG>::Output: Into<u128>, 
[src]

pub fn generate(&mut self) -> u16[src]

Generate a number in the implicit range of the type of the given RNG.

Example

use picorand::{RNG, WyRand, PicoRandGenerate};
let mut rng = RNG::<WyRand, u32>::new(0xDEADBEEF);
let generated = rng.generate();
assert!(generated >= u32::MIN || generated <= u32::MAX);

impl<R: PicoRandRNG> PicoRandGenerate<R, u32> for RNG<R, u32> where
    <R as PicoRandRNG>::Output: Into<u128>, 
[src]

pub fn generate(&mut self) -> u32[src]

Generate a number in the implicit range of the type of the given RNG.

Example

use picorand::{RNG, WyRand, PicoRandGenerate};
let mut rng = RNG::<WyRand, u32>::new(0xDEADBEEF);
let generated = rng.generate();
assert!(generated >= u32::MIN || generated <= u32::MAX);

impl<R: PicoRandRNG> PicoRandGenerate<R, u64> for RNG<R, u64> where
    <R as PicoRandRNG>::Output: Into<u128>, 
[src]

pub fn generate(&mut self) -> u64[src]

Generate a number in the implicit range of the type of the given RNG.

Example

use picorand::{RNG, WyRand, PicoRandGenerate};
let mut rng = RNG::<WyRand, u32>::new(0xDEADBEEF);
let generated = rng.generate();
assert!(generated >= u32::MIN || generated <= u32::MAX);

impl<R: PicoRandRNG> PicoRandGenerate<R, u8> for RNG<R, u8> where
    <R as PicoRandRNG>::Output: Into<u128>, 
[src]

pub fn generate(&mut self) -> u8[src]

Generate a number in the implicit range of the type of the given RNG.

Example

use picorand::{RNG, WyRand, PicoRandGenerate};
let mut rng = RNG::<WyRand, u32>::new(0xDEADBEEF);
let generated = rng.generate();
assert!(generated >= u32::MIN || generated <= u32::MAX);

Auto Trait Implementations

impl<R, T> Send for RNG<R, T> where
    R: Send,
    T: Send
[src]

impl<R, T> Sync for RNG<R, T> where
    R: Sync,
    T: Sync
[src]

impl<R, T> Unpin for RNG<R, T> where
    R: Unpin,
    T: Unpin
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.