Function run

Source
pub fn run<F: Future>(future: F) -> F::Output
Expand description

Run a single future to completion on a bespoke Tokio Runtime.

Every time you call this, a new instance of tokio::runtime::Runtime will be created (see the implementation for details: it is trivial). This is:

  • Reasonable for teaching purposes, in that you do not generally need to set up more than one runtime anyway, and especially do not in basic code like we are showing!

  • Not that far off from what Tokio itself does under the hood in its own tokio::main macro for supporting async fn main.