How to Bridge Sync and Async Code with block_on and spawn_blocking

Use block_on to run async code from main and spawn_blocking to run sync code inside async tasks.

Use block_on to run async code from a synchronous entry point and spawn_blocking to run synchronous code inside an async context without blocking the executor.

use std::thread;
use std::time::Duration;

fn main() {
    // Run async code from sync main
    trpl::block_on(async {
        // Run sync code inside async context
        let result = trpl::spawn_blocking(|| {
            thread::sleep(Duration::from_secs(1));
            "done"
        }).await.unwrap();
        println!("Result: {}", result);
    });
}