[−][src]Struct oorandom::Rand32
A PRNG producing a 32-bit output.
The current implementation is PCG-XSH-RR
.
Methods
impl Rand32
[src]
pub const DEFAULT_INC: u64
[src]
The default value for increment
.
This is basically arbitrary, it comes from the
PCG reference C implementation:
https://github.com/imneme/pcg-c/blob/master/include/pcg_variants.h#L284
pub fn new(seed: u64) -> Self
[src]
Creates a new PRNG with the given seed and a default increment.
pub fn new_inc(seed: u64, increment: u64) -> Self
[src]
Creates a new PRNG. The two inputs, seed
and increment
,
determine what you get; increment
basically selects which
sequence of all those possible the PRNG will produce, and the
seed
selects where in that sequence you start.
Both are arbitrary; increment must be an odd number but this handles that for you
pub fn rand_u32(&mut self) -> u32
[src]
Produces a random u32
in the range [0, u32::MAX]
.
pub fn rand_i32(&mut self) -> i32
[src]
Produces a random i32
in the range [i32::MIN, i32::MAX]
.
pub fn rand_float(&mut self) -> f32
[src]
Produces a random f32
in the range [0.0, 1.0)
.
pub fn rand_range(&mut self, range: Range<u32>) -> u32
[src]
Produces a random within the given bounds. Like any Range
,
it includes the lower bound and excludes the upper one.
This should be faster than Self::rand() % end + start
, but the
real advantage is it's more convenient. Requires that
range.end <= range.start
.
Trait Implementations
impl PartialEq<Rand32> for Rand32
[src]
impl Debug for Rand32
[src]
impl Copy for Rand32
[src]
impl Clone for Rand32
[src]
fn clone(&self) -> Rand32
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,