Struct corosensei::Yielder

source ·
#[repr(transparent)]
pub struct Yielder<Input, Yield> { /* private fields */ }
Expand description

Yielder is an interface provided to a coroutine which allows it to suspend itself and pass values in and out of the coroutine.

Yielder can be freely copied to create multiple references to the same underlying object. However a Yielder cannot be moved to another thread.

Implementations§

source§

impl<Input, Yield> Yielder<Input, Yield>

source

pub fn suspend(&self, val: Yield) -> Input

Suspends the execution of a currently running coroutine.

This function will switch control back to the original caller of Coroutine::resume. This function will then return once the Coroutine::resume function is called again.

source

pub fn on_parent_stack<F, R>(&self, f: F) -> Rwhere F: FnOnce() -> R + Send,

Executes some code on the stack of the parent context (the one who last resumed the current coroutine).

This is particularly useful when executing on a coroutine with limited stack space: stack-heavy operations can be performed in a way that avoids stack overflows on the coroutine stack.

Panics

Any panics in the provided closure are automatically propagated back up to the caller of this function.

Auto Trait Implementations§

§

impl<Input, Yield> !RefUnwindSafe for Yielder<Input, Yield>

§

impl<Input, Yield> Send for Yielder<Input, Yield>

§

impl<Input, Yield> !Sync for Yielder<Input, Yield>

§

impl<Input, Yield> Unpin for Yielder<Input, Yield>

§

impl<Input, Yield> UnwindSafe for Yielder<Input, Yield>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.