The article doesn't actually show what the new syntax looks like. Nor does the article linked in the first paragraph.
What's a simple example of the new syntax?
What's a simple example of the new syntax?
pub async fn do_stuff() {
// ...
}
// elsewhere, inside a fn
// as svnpenn points out
let result = do_stuff().await;https://developer.mozilla.org/Web/JavaScript/Reference/Opera...
chucksmash was concisely showing the syntax for an async function and how you can call it with await.
let result = do_stuff().await;
vs let result = await do_stuff();
not what your parent is talking about.Note "async fn main" on line 15, and the ".await"s on 21 and 24.
Now, if you read my other comment about executors, this is using a crate called "runtime", which handles submitting it for you, see the `#[]` bit on line 14. Regardless, the syntax would look like this even without this crate; it just removes some boilerplate around the executor and submitting your future to it.
use hyper::Client;
let client = Client::new();
let resp = client.get(url).await;