[−][src]Trait generator_extensions::Resumable
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>ⓘ where
G: Generator<(), Return = ()>,
[src]
G: Generator<(), Return = ()>,
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]
G: Generator<R, Return = ()>,
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]
G: Generator<R, Yield = T, Return = T>,
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]
pub fn expect_complete(&mut self, arg: R) -> G::Return
[src]
Implementations on Foreign Types
impl<'a, R, G: Generator<R>> Resumable<'a, R, G> for Pin<&'a mut G>
[src]
pub fn as_mut(&mut self) -> Pin<&mut G>
[src]
pub fn iter(self) -> Iter<'a, G>ⓘ where
G: Generator<(), Return = ()>,
[src]
G: Generator<(), Return = ()>,
pub fn unify<T>(self) -> Unify<'a, R, T, G> where
G: Generator<R, Yield = T, Return = T>,
[src]
G: Generator<R, Yield = T, Return = T>,
pub fn fuse(self) -> Fuse<'a, R, G> where
G: Generator<R, Return = ()>,
[src]
G: Generator<R, Return = ()>,
pub fn states(self) -> States<'a, R, G>
[src]
Implementors
impl<'a, R, G: Generator<R> + Unpin> Resumable<'a, R, G> for &'a mut G
[src]
pub fn as_mut(&mut self) -> Pin<&mut G>
[src]
pub fn iter(self) -> Iter<'a, G>ⓘ where
G: Generator<(), Return = ()>,
[src]
G: Generator<(), Return = ()>,
pub fn unify<T>(self) -> Unify<'a, R, T, G> where
G: Generator<R, Yield = T, Return = T>,
[src]
G: Generator<R, Yield = T, Return = T>,
pub fn fuse(self) -> Fuse<'a, R, G> where
G: Generator<R, Return = ()>,
[src]
G: Generator<R, Return = ()>,