[][src]Trait generator_extensions::Resumable

pub trait Resumable<'a, R, G: Generator<R>> {
#[must_use]    pub fn as_mut(&mut self) -> Pin<&mut G>;
#[must_use] pub fn iter(self) -> Iter<'a, G>

Notable traits for Iter<'a, G>

impl<'a, G: Generator<(), Return = ()>> Iterator for Iter<'a, G> type Item = G::Yield;

    where
        G: Generator<(), Return = ()>
;
#[must_use] pub fn fuse(self) -> Fuse<'a, R, G>
    where
        G: Generator<R, Return = ()>
;
#[must_use] pub fn states(self) -> States<'a, R, G>;
#[must_use] pub fn unify<T>(self) -> Unify<'a, R, T, G>
    where
        G: Generator<R, Yield = T, Return = T>
; #[must_use] pub fn resume(&mut self, arg: R) -> GeneratorState<G::Yield, G::Return> { ... }
pub fn expect_yield(&mut self, arg: R) -> G::Yield { ... }
pub fn expect_complete(&mut self, arg: R) -> G::Return { ... } }

This trait provides extension methods for generators behind references which allow resumption.

This trait is blanket implemented for all suitable references to a generator, namely Pin<&mut Generator> and &mut Generator+Unpin.

To take advantage of these extension methods, simply write:

use generator_extensions::Resumable;

Or, preferably:

use generator_extensions::prelude::*;

Required methods

#[must_use]pub fn as_mut(&mut self) -> Pin<&mut G>[src]

Reborrow the pinned generator.

This method serves the same role as Pin::as_mut.

#[must_use]pub fn iter(self) -> Iter<'a, G>

Notable traits for Iter<'a, G>

impl<'a, G: Generator<(), Return = ()>> Iterator for Iter<'a, G> type Item = G::Yield;
where
    G: Generator<(), Return = ()>, 
[src]

Transforms a pinned generator into an Iterator.

This method is only available on generators which take () as the argument to resume, and which return () on completion. To transform a generator into this form, consider using the unify or states extensions.

#[must_use]pub fn fuse(self) -> Fuse<'a, R, G> where
    G: Generator<R, Return = ()>, 
[src]

Produces a generator which will repeatedly return GeneratorState::Complete(()) instead of panicking, provided that the generator has not already completed.

The generator type must already return ().

#[must_use]pub fn states(self) -> States<'a, R, G>[src]

Produces a generator which yields its states and then completes with ().

#[must_use]pub fn unify<T>(self) -> Unify<'a, R, T, G> where
    G: Generator<R, Yield = T, Return = T>, 
[src]

Transforms a pinned generator with identical Yield and Return types into a generator which yields these values and then completes with ().

Loading content...

Provided methods

#[must_use]pub fn resume(&mut self, arg: R) -> GeneratorState<G::Yield, G::Return>[src]

Resume the pinned generator.

pub fn expect_yield(&mut self, arg: R) -> G::Yield[src]

Resume the pinned generator and panic if it does not yield.

pub fn expect_complete(&mut self, arg: R) -> G::Return[src]

Resume the pinned generator and panic if it does not complete.

Loading content...

Implementations on Foreign Types

impl<'a, R, G: Generator<R>> Resumable<'a, R, G> for Pin<&'a mut G>[src]

Loading content...

Implementors

impl<'a, R, G: Generator<R> + Unpin> Resumable<'a, R, G> for &'a mut G[src]

Loading content...