[−][src]Struct randomize::RandRangeU32
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 Debug for RandRangeU32
[src]
impl PartialEq<RandRangeU32> for RandRangeU32
[src]
fn eq(&self, other: &RandRangeU32) -> bool
[src]
fn ne(&self, other: &RandRangeU32) -> bool
[src]
impl Eq for RandRangeU32
[src]
impl Hash for RandRangeU32
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Copy for RandRangeU32
[src]
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]
fn from(r: RangeInclusive<u32>) -> Self
[src]
impl From<RangeTo<u32>> for RandRangeU32
[src]
impl From<RangeToInclusive<u32>> for RandRangeU32
[src]
fn from(r: RangeToInclusive<u32>) -> Self
[src]
impl Clone for RandRangeU32
[src]
fn clone(&self) -> RandRangeU32
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
Blanket Implementations
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> From<T> for T
[src]
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,