2 ms·
> Async/await is releasing next year, hopefully in Q1. This will simplify future asyncio development and make it much more legible I started using some of the
by realcr 8y ago
> Async/await is releasing next year, hopefully in Q1. This will simplify future asyncio development and make it much more legible
I started using some of the async/await syntax using https://github.com/alexcrichton/futures-await https://github.com/alexcrichton/futures-await about 6 months ago. I had much problems with understanding the compiler errors because async functions were created using macros, and the compiler was not going a very good job at showing the errors (Or maybe I was missing some information about how to do this).
However, if you are willing to work with nightly Rust, you will be able to start using Futures 0.3 with async and await!. Using the async and await! syntax gave me such a huge boost to productivity that I am willing to walk on the edge and use the alpha version with nightly Rust (futures-preview = "0.3.0-alpha.10").
The integration with things like clocks and networking (The things you get from Tokio) are not yet perfect, but there is a compatibility layer you can use that works reasonably well. There is also the Romio project (https://github.com/withoutboats/romio https://github.com/withoutboats/romio) as an attempt to make a minimal Tokio that works with the new Futures syntax. I recently saw this post by jsdw, it might help you get started: https://jsdw.me/posts/rust-asyncawait-preview/ https://jsdw.me/posts/rust-asyncawait-preview/
I already wrote large amounts of code using Futures 0.3 with async/await for the offst project (https://github.com/freedomlayer/offst https://github.com/freedomlayer/offst). A very simple example you can start with is the Timer module, providing time ticks over channels to other parts of the system. It's code is pretty self contained and shows what could be achieved with the new async/await syntax. You can find it here: https://github.com/freedomlayer/offst/blob/master/components/timer/src/timer.rs https://github.com/freedomlayer/offst/blob/master/components...
- Dowwie 8y agoThe productivity gains from async/await are substantial. The community cannot release this to stable quickly enough!