Re:Rust async-await status report 2
by steveklabnik on Wednesday July 10, 2019 @04:53PM
(#20406440)
Yes, this was suggested. I don’t remember the exact reason it was rejected, other than maybe being a more unusual choice with no significantly clear benefit.
I think part of it too was that this works better if your futures were to execute immediately like promises; this would make a lot of code serial by default.
Re:Rust async-await status report 2
by Buttons840 on Wednesday July 10, 2019 @03:33PM
(#20405603)
Those hardly look different. From the context of the parent comments I thought you were going to suggest something completely different, but it looks like it's just a small syntax change.
Re:Rust async-await status report 2
by atombender on Wednesday July 10, 2019 @03:37PM
(#20405652)
The semantics are clear and have already stabilized. The discussions the last year have almost entirely been about syntax.
It seems to me that you'll generally await futures in high-level code. Keeping values around as futures is the minority case. So instead of asking to await one could automatically insert awaiting code whenever a future needs to be converted to a real value. Instead of this:
...you could simply have this: ...which would await both the inner and outer futures: process_image() expects an Image, and fetch() returns a Future<Image>, so it can be automatically awaited and coerced.Sometimes you do want a future when you don't want to wait right away, e.g. when storing a bunch of pending operations or something. For that, one could tell Rust not to automatically coerce futures:
...although this, too, could presumably be done transparently for you, since Rust knows you're assigning to a future.