pub struct Coroutine { /* private fields */ }

Implementations

By default coroutines are being polled each frame, inside the “next_frame()”

start_coroutine(async move {
   println!("a");
   next_frame().await;
   println!("b");
}); // <- coroutine is created, but not yet polled
println!("c"); // <- first print, "c"
next_frame().await; // coroutine will be polled for the first time
                    // will print "a"
println!("d");      // "d"
next_frame().await; // coroutine will be polled second time, pass next_frame().await and will print "b"

will print “cadb” (there is a test for it, “tests/coroutine.rs:coroutine_execution_order” )

But, sometimes, automatic polling is not nice good example - game pause. Imagine a player that have some “update” function and some coroutines runned. During the pause “update” just early quit, but what with the coroutines?

“set_manual_poll” allows to control how coroutine is beng polled after set_manual_poll() coroutine will never be polled automatically so player will need to poll all its coroutines inside “update” function

Poll coroutine once and advance coroutine’s timeline by delta_time Things like wait_for_seconds will wait for time in this local timeline` Will panic if coroutine.manual_poll == false

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.