3 ms·
Postfixed and preceded by a dot is my understanding: pub async fn do_stuff() { // ... } // elsewhere, inside a fn // as svnpenn points
by chucksmash 7y ago
Postfixed and preceded by a dot is my understanding:
pub async fn do_stuff() {
// ...
}
// elsewhere, inside a fn
// as svnpenn points out
let result = do_stuff().await;
- svnpenn 7y agoawait goes inside the function, at least thats how its done with JavaScript - do you have evidence otherwise? https://developer.mozilla.org/Web/JavaScript/Reference/Operators/await https://developer.mozilla.org/Web/JavaScript/Reference/Opera...
- steveklabnik 7y agoI read your parent as suggesting that the line with `let` was made inside of another `async fn`. You're correct that you can only .await inside of one. You shouldn't be downvoted.
- k__ 7y agoThey worte explicitly that Rust went a different way than C#/JS
- steveklabnik 7y agoIt's true, but that's around let result = do_stuff().await; vs let result = await do_stuff(); not what your parent is talking about.
- k__ 7y agoAh, they meant like await goes into async functions etc.
- SamBam 7y agoI think it should be fairly clear that it's inside an async function, I mostly don't think that was part of the question, which was about syntax. chucksmash was concisely showing the syntax for an async function and how you can call it with await.
- deleted 7y ago[deleted]