pub struct Yield;Expand description
A unit structure that implements IntoFuture for a clean .await syntax.
Using Yield.await is the preferred way to cooperatively yield control back
to the [Executor]. It ensures other tasks (like input handling) can run.
§Example
async fn heavy_computation() {
for i in 0..1000 {
do_work(i);
// Yield every iteration to prevent system hang
Yield.await;
}
}Trait Implementations§
Source§impl IntoFuture for Yield
impl IntoFuture for Yield
Source§type IntoFuture = _Yield
type IntoFuture = _Yield
Which kind of future are we turning this into?
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Creates a future from a value. Read more
Auto Trait Implementations§
impl Freeze for Yield
impl RefUnwindSafe for Yield
impl Send for Yield
impl Sync for Yield
impl Unpin for Yield
impl UnwindSafe for Yield
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