[−][src]Struct genawaiter::rc::Gen
This is a generator which stores its state on the heap.
See the module-level docs for examples.
Methods
impl<Y, R, F: Future> Gen<Y, R, F>
[src]
pub fn new(start: impl FnOnce(Co<Y, R>) -> F) -> Self
[src]
Creates a new generator from a function.
The function accepts a Co
object, and returns a future. Every time
the generator is resumed, the future is polled. Each time the future is
polled, it should do one of two things:
- Call
co.yield_()
, and then returnPoll::Pending
. - Drop the
Co
, and then returnPoll::Ready
.
Typically this exchange will happen in the context of an async fn
.
See the module-level docs for examples.
pub fn resume_with(&mut self, arg: R) -> GeneratorState<Y, F::Output>
[src]
Resumes execution of the generator.
arg
is the resume argument. If the generator was previously paused by
awaiting a future returned from co.yield()
, that future will complete,
and return arg
.
If the generator yields a value, Yielded
is returned. Otherwise,
Completed
is returned.
See the module-level docs for examples.
impl<Y, F: Future> Gen<Y, (), F>
[src]
pub fn resume(&mut self) -> GeneratorState<Y, F::Output>
[src]
Resumes execution of the generator.
If the generator yields a value, Yielded
is returned. Otherwise,
Completed
is returned.
See the module-level docs for examples.
pub fn async_resume(
&mut self
) -> impl Future<Output = GeneratorState<Y, F::Output>> + '_
[src]
&mut self
) -> impl Future<Output = GeneratorState<Y, F::Output>> + '_
Resumes execution of the generator.
If the generator pauses without yielding, Poll::Pending
is returned.
If the generator yields a value, Poll::Ready(Yielded)
is returned.
Otherwise, Poll::Ready(Completed)
is returned.
See the module-level docs for examples.
Trait Implementations
impl<Y, R, F: Future> Coroutine for Gen<Y, R, F>
[src]
type Yield = Y
The type of value this generator yields.
type Resume = R
The type of value this generator accepts as a resume argument.
type Return = F::Output
The type of value this generator returns upon completion.
fn resume_with(
self: Pin<&mut Self>,
arg: R
) -> GeneratorState<Self::Yield, Self::Return>
[src]
self: Pin<&mut Self>,
arg: R
) -> GeneratorState<Self::Yield, Self::Return>
impl<Y, F: Future<Output = ()>> IntoIterator for Gen<Y, (), F>
[src]
Auto Trait Implementations
impl<Y, R, F> !Send for Gen<Y, R, F>
impl<Y, R, F> !Sync for Gen<Y, R, F>
impl<Y, R, F> Unpin for Gen<Y, R, F>
impl<Y, R, F> !UnwindSafe for Gen<Y, R, F>
impl<Y, R, F> !RefUnwindSafe for Gen<Y, R, F>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,