Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary async block in tutorial code #719

Closed
tae-soo-kim opened this issue Oct 4, 2023 · 2 comments
Closed

Unnecessary async block in tutorial code #719

tae-soo-kim opened this issue Oct 4, 2023 · 2 comments

Comments

@tae-soo-kim
Copy link

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
Copy link
Contributor

Darksonn commented Oct 4, 2023

Indeed, they are the same.

@tae-soo-kim
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants