pub struct GeneratorToken<Y, A = ()>(/* private fields */);Expand description
A generator token ties together the executor and the generator itself.
It is what allows us to yield values back out of the generator.
Implementations§
Source§impl<Y, A> GeneratorToken<Y, A>
impl<Y, A> GeneratorToken<Y, A>
Sourcepub async fn yield_(&self, value: Y) -> A
pub async fn yield_(&self, value: Y) -> A
Yield a value from this generator, returning control back to the caller.
§Panics
Panics if evaluated in the context of a generator other than the one this token was created for.
Sourcepub async fn argument(&self) -> A
pub async fn argument(&self) -> A
Get the current argument without yielding.
Normally yield_ will yield a value and then read in the next
argument. However, the very first argument passed in to the generator
happens before the first call to yield_. This method is used to read
that initial argument passed into the generator.
§Panics
- Panics if evaluated in the context of a generator other than the one this token was created for.
- Panics if there is no argument saved in the generator context. (e.g. yield has already been called or argument was called multiple times)
Auto Trait Implementations§
impl<Y, A> Freeze for GeneratorToken<Y, A>
impl<Y, A> RefUnwindSafe for GeneratorToken<Y, A>where
Y: RefUnwindSafe,
A: RefUnwindSafe,
impl<Y, A> Send for GeneratorToken<Y, A>
impl<Y, A> Sync for GeneratorToken<Y, A>
impl<Y, A> Unpin for GeneratorToken<Y, A>
impl<Y, A> UnsafeUnpin for GeneratorToken<Y, A>
impl<Y, A> UnwindSafe for GeneratorToken<Y, A>where
Y: UnwindSafe,
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more