expression

Current-thread runtime

A current-thread runtime schedules async tasks on the thread driving it. Blocking work can still require other threads. The builder lets a synchronous entry point choose configuration. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): 12 Common mistake: Expecting spawned tasks to continue progressing between block_on calls on this scheduler.

Formal Syntax & Structure

rust syntaxrust
Builder::new_current_thread().build()

Working Example

Example Snippetrust
fn main() {    let rt = tokio::runtime::Builder::new_current_thread().build().unwrap();    let answer = rt.block_on(async { 7 + 5 });    println!("{answer}");}
Rust Reference