[][src]Struct randomize::RandRangeU32

pub struct RandRangeU32 { /* fields omitted */ }

An inclusive random range with a u32 low and high value.

This type utilizes u64 math internally, so it's not entirely suitable for 32-bit machines. It'll run, but more slowly than you might like if you're using this in a tight loop.

Methods

impl RandRangeU32[src]

pub fn try_new(a: u32, b: u32) -> Option<Self>[src]

Attempts to make a new inclusive random range. Inputs can be in either order.

Failure

If the inputs are 0 and core::u32::MAX

pub const fn new(a: u32, b: u32) -> Self[src]

As try_new, but const, and panics on failure.

pub const fn low(&self) -> u32[src]

Inclusive low end of this range.

pub const fn high(&self) -> u32[src]

Inclusive high end of this range.

pub fn place_in_range(&self, val: u32) -> Option<u32>[src]

Given a uniform input, produces uniform output in range or fails.

You aren't really intended to use this directly, instead you probably want to use sample.

Failure

Most ranges don't evenly distribute across the u32 space, so some values will fail to end up in range.

pub fn sample(&self, gen: &mut PCG32) -> u32[src]

Sample from a PCG32 one or more times to get a value in range.

Trait Implementations

impl From<Range<u32>> for RandRangeU32[src]

impl From<RangeFrom<u32>> for RandRangeU32[src]

impl From<RangeFull> for RandRangeU32[src]

impl From<RangeInclusive<u32>> for RandRangeU32[src]

impl From<RangeTo<u32>> for RandRangeU32[src]

impl From<RangeToInclusive<u32>> for RandRangeU32[src]

impl PartialEq<RandRangeU32> for RandRangeU32[src]

impl Eq for RandRangeU32[src]

impl Hash for RandRangeU32[src]

impl Debug for RandRangeU32[src]

impl Copy for RandRangeU32[src]

impl Clone for RandRangeU32[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]

type Error = Infallible

The type returned in the event of a conversion error.

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

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.

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

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

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