A final proposal for await syntax

A scenario just occurred to me, which I haven’t seen discussed before. I believe .await makes it harder to refactor code. Imagine your line becomes too long or too complicated and that you would like to extract some of the values into local variables. So you start with

return some_expression.await + other_expression.await;

You now refactor this into

let foo = some_expression.await;
let bar = other_expression.await;
return foo + bar;

Seems simple enough. However, there is now an observable difference between the above program and this program:

let bar = other_expression.await;
let foo = some_expression.await;
return foo + bar;

This feels like a big deviation from how Rust programs normally function and I bet that inexperienced Rust developers wont catch this on a first reading since it looks like simple field accesses.

10 Likes