How do I synchronously return a value calculated in an asynchronous Future in stable Rust?

Standard library futures Let’s use this as our minimal, reproducible example: async fn example() -> i32 { 42 } Call executor::block_on: use futures::executor; // 0.3.1 fn main() { let v = executor::block_on(example()); println!(“{}”, v); } Tokio Use the tokio::main attribute on any function (not just main!) to convert it from an asynchronous function to a … Read more