2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-01-16 18:59:55 +00:00
async-std/examples/task-name.rs

20 lines
372 B
Rust
Raw Normal View History

2019-08-08 12:44:48 +00:00
//! Spawns a named task that prints its name.
#![feature(async_await)]
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;
})
}