Why async/await?

When we call a simple non-async function we have also to wait for execution time .
For example:

simple ( ) ;
fn simple ( ) { 1 + 1 }

So, what is the difference between waiting for calculation 1 + 1 and waiting for web response ?

You might want to read up on the subject in the Async Rust Book.
It covers motivation, how to get started, and how to use it.

2 Likes

The short answer is that if the thing you are waiting for is IO, then you don't actually have to wait and can do something else in the mean-time. You may find this article illuminating.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.