# 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.

## Implementations on Foreign Types

### `impl SampleRange for i8`
[src]

#### `fn construct_range(low: i8, high: i8) -> Range<i8>`
[src]

#### `fn sample_range<R: Rng>(r: &Range<i8>, rng: &mut R) -> i8`
[src]

### `impl SampleRange for i16`
[src]

#### `fn construct_range(low: i16, high: i16) -> Range<i16>`
[src]

#### `fn sample_range<R: Rng>(r: &Range<i16>, rng: &mut R) -> i16`
[src]

### `impl SampleRange for i32`
[src]

#### `fn construct_range(low: i32, high: i32) -> Range<i32>`
[src]

#### `fn sample_range<R: Rng>(r: &Range<i32>, rng: &mut R) -> i32`
[src]

### `impl SampleRange for i64`
[src]

#### `fn construct_range(low: i64, high: i64) -> Range<i64>`
[src]

#### `fn sample_range<R: Rng>(r: &Range<i64>, rng: &mut R) -> i64`
[src]

### `impl SampleRange for isize`
[src]

#### `fn construct_range(low: isize, high: isize) -> Range<isize>`
[src]

#### `fn sample_range<R: Rng>(r: &Range<isize>, rng: &mut R) -> isize`
[src]

### `impl SampleRange for u8`
[src]

#### `fn construct_range(low: u8, high: u8) -> Range<u8>`
[src]

#### `fn sample_range<R: Rng>(r: &Range<u8>, rng: &mut R) -> u8`
[src]

### `impl SampleRange for u16`
[src]

#### `fn construct_range(low: u16, high: u16) -> Range<u16>`
[src]

#### `fn sample_range<R: Rng>(r: &Range<u16>, rng: &mut R) -> u16`
[src]

### `impl SampleRange for u32`
[src]

#### `fn construct_range(low: u32, high: u32) -> Range<u32>`
[src]

#### `fn sample_range<R: Rng>(r: &Range<u32>, rng: &mut R) -> u32`
[src]

### `impl SampleRange for u64`
[src]

#### `fn construct_range(low: u64, high: u64) -> Range<u64>`
[src]

#### `fn sample_range<R: Rng>(r: &Range<u64>, rng: &mut R) -> u64`
[src]

### `impl SampleRange for usize`
[src]

#### `fn construct_range(low: usize, high: usize) -> Range<usize>`
[src]

#### `fn sample_range<R: Rng>(r: &Range<usize>, rng: &mut R) -> usize`
[src]

### `impl SampleRange for f32`
[src]

#### `fn construct_range(low: f32, high: f32) -> Range<f32>`
[src]

#### `fn sample_range<R: Rng>(r: &Range<f32>, rng: &mut R) -> f32`
[src]

### `impl SampleRange for f64`
[src]

#### `fn construct_range(low: f64, high: f64) -> Range<f64>`
[src]

#### `fn sample_range<R: Rng>(r: &Range<f64>, rng: &mut R) -> f64`
[src]

## Implementors

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## 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`)