Using futures is a common technique in JavaScript, TypeScript, C#, and similar technologies—made popular by the addition of the async/await keywords in their syntax. In a nutshell, futures (or promises) is a function's guarantee that, at some point, the handle will be resolved and the actual value will be returned. However, there is no explicit time when this is going to happen—but you can schedule entire chains of promises that are resolved after each other. How does this work in Rust? Let's find out in this recipe.
At the time of writing, async/await were under heavy development. Depending on when you are reading this book, the examples may have stopped working. In this case, we ask you to open an issue in the accompanying repository so we can fix the issues. For updates, check the Rust async working group's...