[−][src]Struct randomize::BoundedRandU32
Stores the values to sample a number in 0 .. N
Making one of these performs a division operation. In comparison,
Gen32::next_bounded
will avoid needing to do a division much of the
time. Thus, unless you need to sample repeatedly from a specific bounded
range, simply calling next_bounded
directly might be more efficient.
Implementations
impl BoundedRandU32
[src]
pub const fn new(count: u32) -> Self
[src]
pub const fn try_new(count: u32) -> Option<Self>
[src]
pub const fn count(self) -> u32
[src]
The number of possible outputs.
pub const fn place_in_range(self, val: u32) -> Option<u32>
[src]
Given a u32
, place it into this bounded range.
Failure
- If the value is such that it doesn't fit evenly it is rejected.
pub fn sample<G: Gen32 + ?Sized>(self, gen: &mut G) -> u32
[src]
Given a gen, sample from the gen until place_in_range
succeeds.
Trait Implementations
impl Clone for BoundedRandU32
[src]
fn clone(&self) -> BoundedRandU32
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for BoundedRandU32
[src]
impl Debug for BoundedRandU32
[src]
impl Eq for BoundedRandU32
[src]
impl Hash for BoundedRandU32
[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 PartialEq<BoundedRandU32> for BoundedRandU32
[src]
fn eq(&self, other: &BoundedRandU32) -> bool
[src]
fn ne(&self, other: &BoundedRandU32) -> bool
[src]
impl StructuralEq for BoundedRandU32
[src]
impl StructuralPartialEq for BoundedRandU32
[src]
Auto Trait Implementations
impl RefUnwindSafe for BoundedRandU32
impl Send for BoundedRandU32
impl Sync for BoundedRandU32
impl Unpin for BoundedRandU32
impl UnwindSafe for BoundedRandU32
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut 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> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,