In contrast, in Rust, calling an async function does not do any scheduling in and of itself, which means that we can compose a complex nest of futures without incurring a per-future cost. As an end-user, though, the main thing you’ll notice is that futures feel “lazy”: they don’t do anything until you await them.
If I have 3 futures that I’d like to run in parallel, how do I actually “start” them running before I block on any of their results coming back?
For example:
a = async1()
b = async2()
c = async3()
// ideally a/b/c are all running "in the background" at this point
a.await
b.await
c.await
If I have 3 futures that I’d like to run in parallel, how do I actually “start” them running before I block on any of their results coming back?
For example:
Or am I misreading what they’re saying there?
For this use case you can join multiple Futures into one, for more info: https://rust-lang.github.io/async-book/06_multiple_futures/02_join.html
That looks like exactly the solution for this. Thanks!