# SampleRange in rand::distributions::uniform - Rust
Range that supports generating a single sample efficiently.
Keywords: rust, rustlang, rust-lang, SampleRange

# Trait rand::distributions::uniform::SampleRange

source · [−]

    pub trait SampleRange<T> {
        fn sample_single<R: RngCore + ?Sized>(self, rng: &mut R) -> T;
        fn is_empty(&self) -> bool;
    }

Expand description

Range that supports generating a single sample efficiently.

Any type implementing this trait can be used to specify the sampled range for `Rng::gen_range`.

## Required Methods

source

#### fn sample_single<R: RngCore + ?Sized>(self, rng: &mut R) -> T

Generate a sample from the given range.

source

#### fn is_empty(&self) -> bool

Check whether the range is empty.

## Implementations on Foreign Types

source

### impl<T: SampleUniform + PartialOrd> SampleRange<T> for Range<T>

source

#### fn sample_single<R: RngCore + ?Sized>(self, rng: &mut R) -> T

source

#### fn is_empty(&self) -> bool

source

### impl<T: SampleUniform + PartialOrd> SampleRange<T> for RangeInclusive<T>

source

#### fn sample_single<R: RngCore + ?Sized>(self, rng: &mut R) -> T

source

#### fn is_empty(&self) -> bool

## Implementors