# 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 i8`
- `impl SampleRange for i16`
- `impl SampleRange for i32`
- `impl SampleRange for i64`
- `impl SampleRange for isize`
- `impl SampleRange for u8`
- `impl SampleRange for u16`
- `impl SampleRange for u32`
- `impl SampleRange for u64`
- `impl SampleRange for usize`
- `impl SampleRange for f32`
- `impl SampleRange for f64`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)