async-std 1.13.1

Deprecated in favor of `smol` - Async version of the Rust standard library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Spawns a named task that prints its name.

use async_std::task;

async fn print_name() {
    println!("My name is {:?}", task::current().name());
}

fn main() {
    task::block_on(async {
        task::Builder::new()
            .name("my-task".to_string())
            .spawn(print_name())
            .unwrap()
            .await;
    })
}