Struct pushgen::generators::SliceGenerator
source · pub struct SliceGenerator<'a, T> { /* private fields */ }
Expand description
A generator that generates values from a slice.
Example
let data = [1, 2, 3, 4];
let mut sum = 0;
SliceGenerator::new(&data).for_each(|x| sum += x);
assert_eq!(sum, 10);
Implementations§
Trait Implementations§
source§impl<'a, T: Clone> Clone for SliceGenerator<'a, T>
impl<'a, T: Clone> Clone for SliceGenerator<'a, T>
source§fn clone(&self) -> SliceGenerator<'a, T>
fn clone(&self) -> SliceGenerator<'a, T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<'a, T> Generator for SliceGenerator<'a, T>
impl<'a, T> Generator for SliceGenerator<'a, T>
source§fn run(
&mut self,
output: impl FnMut(Self::Output) -> ValueResult
) -> GeneratorResult
fn run( &mut self, output: impl FnMut(Self::Output) -> ValueResult ) -> GeneratorResult
Run the generator, emitting values to the
output
closure. Read moresource§fn try_advance(&mut self, n: NonZeroUsize) -> (usize, GeneratorResult)
fn try_advance(&mut self, n: NonZeroUsize) -> (usize, GeneratorResult)
Try to advance the generator
n
values, ignoring them. Read moresource§impl<'a, T> ReverseGenerator for SliceGenerator<'a, T>
impl<'a, T> ReverseGenerator for SliceGenerator<'a, T>
source§fn run_back(
&mut self,
output: impl FnMut(Self::Output) -> ValueResult
) -> GeneratorResult
fn run_back( &mut self, output: impl FnMut(Self::Output) -> ValueResult ) -> GeneratorResult
Run a generator backwards, producing values from the end to the beginning.
source§fn try_advance_back(&mut self, n: NonZeroUsize) -> (usize, GeneratorResult)
fn try_advance_back(&mut self, n: NonZeroUsize) -> (usize, GeneratorResult)
Tries to advance the generator from the back by
n
values.