pub struct Coroutine<Y, T, R> { /* private fields */ }Expand description
A coroutine that can yield values of type Y, can be resumed with a value of type R and
completes with a value of type T.
Implementations§
Source§impl<Y, T, R> Coroutine<Y, T, R>where
T: 'static,
impl<Y, T, R> Coroutine<Y, T, R>where
T: 'static,
Sourcepub fn new<F>(f: impl FnOnce(YieldHandle<Y, R>, R) -> F + 'static) -> Selfwhere
F: Future<Output = T> + 'static,
pub fn new<F>(f: impl FnOnce(YieldHandle<Y, R>, R) -> F + 'static) -> Selfwhere
F: Future<Output = T> + 'static,
Creates a new coroutine from a function that takes the YieldHandle and the initial
value. The function must return a future that resolves to the final value of type T.
Sourcepub fn resume_with(&mut self, resume: R) -> State<Y, T>
pub fn resume_with(&mut self, resume: R) -> State<Y, T>
Resumes the coroutine with a value of type R.
Auto Trait Implementations§
impl<Y, T, R> Freeze for Coroutine<Y, T, R>
impl<Y, T, R> !RefUnwindSafe for Coroutine<Y, T, R>
impl<Y, T, R> !Send for Coroutine<Y, T, R>
impl<Y, T, R> !Sync for Coroutine<Y, T, R>
impl<Y, T, R> Unpin for Coroutine<Y, T, R>
impl<Y, T, R> !UnwindSafe for Coroutine<Y, T, R>
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