Trait rand::distributions::range::SampleRange
[−]
[src]
pub trait SampleRange: Sized {
fn construct_range(low: Self, high: Self) -> Range<Self>;
fn sample_range<R: Rng>(r: &Range<Self>, rng: &mut R) -> Self;
}The helper trait for types that have a sensible way to sample
uniformly between two values. This should not be used directly,
and is only to facilitate Range.
Required Methods
fn construct_range(low: Self, high: Self) -> Range<Self>
Construct the Range object that sample_range
requires. This should not ever be called directly, only via
Range::new, which will check that low < high, so this
function doesn't have to repeat the check.
fn sample_range<R: Rng>(r: &Range<Self>, rng: &mut R) -> Self
Sample a value from the given Range with the given Rng as
a source of randomness.
Implementors
impl SampleRange for i8impl SampleRange for i16impl SampleRange for i32impl SampleRange for i64impl SampleRange for isizeimpl SampleRange for u8impl SampleRange for u16impl SampleRange for u32impl SampleRange for u64impl SampleRange for usizeimpl SampleRange for f32impl SampleRange for f64