[][src]Trait generator_extensions::IntoGenerator

pub trait IntoGenerator {
    type Resume;
    type Yield;
    type Return;
    type Generator: Generator<Self::Resume, Yield = Self::Yield, Return = Self::Return>;
#[must_use]    pub fn into_generator(self) -> Self::Generator;
}

This trait represents a value which can be transformed into a Generator.

Currently, this trait is blanket implemented for all Iterator types as well as for the Gen wrapper type.

To take advantage of these extension methods, simply write:

use generator_extensions::IntoGenerator;

Or, preferably:

use generator_extensions::prelude::*;

Notes

This trait is unfortunately not implemented for compiler-generated types, as those desugared types could theoretically implement multiple distinct generator traits. This does not occur today and is very unlikely to occur in the future, but the Rust trait system is rightly unable to express this fact.

To work around this, the newtype wrapper Gen is provided by this crate.

Associated Types

type Resume[src]

The argument to resume the generator.

type Yield[src]

The type of value the generator yields.

type Return[src]

The type of value the generator returns.

type Generator: Generator<Self::Resume, Yield = Self::Yield, Return = Self::Return>[src]

Type full type of the generator.

Loading content...

Required methods

#[must_use]pub fn into_generator(self) -> Self::Generator[src]

Convert this value into a Generator.

Loading content...

Implementors

impl<I: Iterator> IntoGenerator for I[src]

type Resume = ()

type Yield = I::Item

type Return = ()

type Generator = GenIter<I>

impl<R, G: Generator<R>> IntoGenerator for Gen<R, G>[src]

type Resume = R

type Yield = G::Yield

type Return = G::Return

type Generator = G

Loading content...