pub trait IntoGenerator {
    type Output;
    type IntoGen: Generator<Output = Self::Output>;

    // Required method
    fn into_gen(self) -> Self::IntoGen;
}
Expand description

Conversion to a generator.

By implementing IntoGenerator for a type you define how that type will be converted to a generator.

Required Associated Types§

source

type Output

Data-type generated by the generator.

source

type IntoGen: Generator<Output = Self::Output>

Which kind of generator are we turning this into?

Required Methods§

source

fn into_gen(self) -> Self::IntoGen

Creates a generator from a value.

See the module-level documentation for more.

Examples

Basic usage:

use pushgen::IntoGenerator;
use crate::pushgen::GeneratorExt;
let v = vec![1, 2, 3];
let mut gen = v.into_gen();

let mut output: Vec<i32> = Vec::new();
gen.for_each(|x| output.push(x));
assert_eq!(output, [1, 2, 3]);

Implementations on Foreign Types§

source§

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

§

type Output = T

§

type IntoGen = ArrayGenerator<T, N>

source§

fn into_gen(self) -> Self::IntoGen

source§

impl<'a, T, const N: usize> IntoGenerator for &'a [T; N]

§

type Output = &'a T

§

type IntoGen = SliceGenerator<'a, T>

source§

fn into_gen(self) -> Self::IntoGen

source§

impl<'a, T> IntoGenerator for &'a [T]

§

type Output = &'a T

§

type IntoGen = SliceGenerator<'a, T>

source§

fn into_gen(self) -> Self::IntoGen

source§

impl<T> IntoGenerator for Vec<T>

Available on crate feature std only.
§

type Output = T

§

type IntoGen = FromIter<IntoIter<T, Global>>

source§

fn into_gen(self) -> Self::IntoGen

source§

impl<'t, T> IntoGenerator for &'t Option<T>

source§

impl<'a, T> IntoGenerator for &'a Vec<T>

Available on crate feature std only.
§

type Output = &'a T

§

type IntoGen = SliceGenerator<'a, T>

source§

fn into_gen(self) -> Self::IntoGen

source§

impl<T> IntoGenerator for Option<T>

§

type Output = T

§

type IntoGen = OptionGen<T>

source§

fn into_gen(self) -> Self::IntoGen

Implementors§

source§

impl<G: Generator> IntoGenerator for G

§

type Output = <G as Generator>::Output

§

type IntoGen = G