The past two days I've had a chance to use async/await in Rust for the first time. It was a useful comparison against the old way since I was refactoring existing code to use it.
It made things *much* easier and simpler.
1/5
1
6
Using futures and streams with chained callback functions (the old way) instead of async/await (the new way) led to lots of struggling over ownership and lifetimes (and fighting with the borrow checker). In the same code restructured to use async/await, it's much easier.
2/5
1
1
It feels like a big improvement -- and probably a bigger difference than the introduction of async/await in Javascript.
3/5
1
1
That said, I'd note that there was also one unfair advantage with the new way, which is that one of my dependent libraries, crates.io/crates/irc , has restructured to get along a better with the new tokio/futures infrastructure than it did with the old.
4/5
1
Old code (before tokio/futures update):
github.com/dbaron/wgmeeting-…
Old code (after tokio/futures update):
github.com/dbaron/wgmeeting-…
New code:
github.com/dbaron/wgmeeting-…
Much nicer.
(I admit I don't write a whole lot of rust, so I'm sure my code is non-idiomatic in various ways.)
5/5
Jul 19, 2020 · 12:54 AM UTC
3
