tokio-rs / website

Website for the Tokio project
https://tokio.rs
MIT License
231 stars 328 forks source link

Unnecessary async block in tutorial code #719

Closed tae-soo-kim closed 1 year ago

tae-soo-kim commented 1 year ago

https://github.com/tokio-rs/website/blob/48e89baca324065d5b608d776dc31f99e5efc1bc/tutorial-code/spawning/src/main.rs#L15C8-L15C8

I am learning Tokio with its tutorial. The tutorial uses an async block which I think is unnecessary:

tokio::spawn(async move {
    process(socket).await;
});

can be simplified into:

tokio::spawn(process(socket));

I'm not quite sure so I opened this issue to confirm this. If this is true, I think it worth explanation in the tutorial. If not, I'd like to know what are the differences between these two.

Darksonn commented 1 year ago

Indeed, they are the same.

tae-soo-kim commented 1 year ago

Thanks for confirming this. Adding a note in the tutorial could be helpful for readers.