thread-async 0.1.0

Execute a task in a new thread and await the result asynchronously
Documentation
thread-async-0.1.0 has been yanked.

Crate thread_async

Crates.io License

Execute a task in a new thread and await the result asynchronously.

use std::{thread, time};

#[tokio::main]
async fn main() {
    let output = thread_async::run(|| {
        thread::sleep(time::Duration::from_millis(250));
        42
    })
    .await;

    assert_eq!(output, 42);
}