pub trait DiscreteGenerator: Generator<usize> {
    // Required method
    fn len(&self) -> usize;

    // Provided methods
    fn first(&self) -> Option<Self::Output> { ... }
    fn last(&self) -> Option<Self::Output> { ... }
    fn is_empty(&self) -> bool { ... }
    fn into_iter(self) -> IntoIter<Self>
       where Self: Sized { ... }
    fn iter(&self) -> IntoIter<&Self> { ... }
    fn repeat(self) -> Repeat<Self>
       where Self: Sized { ... }
}
Expand description

Specialized Generator with input of type usize.

All DiscreteGenerator must return valid values when using inputs less than the value returned by their len() method.

Required Methods§

source

fn len(&self) -> usize

Returns the minimum amount of elements the generator can create.

The generator has to guarantee that every usize number lower than the returned number has to create a valid element.

Provided Methods§

source

fn first(&self) -> Option<Self::Output>

Returns the first element of the generator, or None if it is empty.

source

fn last(&self) -> Option<Self::Output>

Returns the last element of the generator, or None if it is empty.

source

fn is_empty(&self) -> bool

Returns true if the generator does not generate any elements.

source

fn into_iter(self) -> IntoIter<Self>where Self: Sized,

Convert generator to an iterator which steps through all generatable values.

source

fn iter(&self) -> IntoIter<&Self>

Create iterator which steps through all generatable values.

source

fn repeat(self) -> Repeat<Self>where Self: Sized,

Transfrom generator to one which repeats its elements.

Implementations on Foreign Types§

source§

impl<T: Copy> DiscreteGenerator for &[T]

source§

fn len(&self) -> usize

source§

impl<T: Copy> DiscreteGenerator for Vec<T>

source§

fn len(&self) -> usize

source§

impl<T: Copy, const N: usize> DiscreteGenerator for [T; N]

source§

fn len(&self) -> usize

source§

impl<G: DiscreteGenerator + ?Sized> DiscreteGenerator for &G

source§

fn len(&self) -> usize

Implementors§