Rust 1.39.0 stable update adds async-await
The latest version of Rust is now available and introduces a big change for the language. 1.39.0 adds async-await. This feature moves out of beta and is now stable. The use of asynchronous code allows users to run multiple tasks concurrently on the same OS thread. See what other changes are now available to Rust, Cargo, and Clippy.
It’s been a good year for Rust. The latest State of the Octoverse 2019 report reveals that Rust is the second fasting growing programming language, with a change of 235%. The language’s community is quickly expanding.
Will the language continue to grow with the new changes made in the latest release?
The biggest change in version 1.39.0 is the introduction of async-await. This feature was first proposed back in 2016 and now three years later, it is available in stable Rust.
From the Asynchronous Programming in Rust guide:
Asynchronous code allows us to run multiple tasks concurrently on the same OS thread…Overall, asynchronous applications have the potential to be much faster and use fewer resources than a corresponding threaded implementation. However, there is a cost. Threads are natively supported by the operating system, and using them doesn’t require any special programming model– any function can create a thread, and calling a function that uses threads is usually just as easy as calling any normal function. However, asynchronous functions require special support from the language or libraries.
In order to use async-await, use
async fn syntax instead of just
async fn returns a
Future. , which is waiting to run on an executor.
Future, you use
This new feature marks a big shift in the language. Future updates will include more improvements, extensions, and ecosystem expansions for async-await. Since the beta release, Rust has already changed and improved previously unhelpful diagnostics.
Check out the async-await guide and learn how to build an echo server.