3 min read

Less than two months after announcing Rust 1.38, the Rust team announced the release of Rust 1.39 yesterday. The new release brings the stable version of the async-await syntax, which will allow users to not only define async functions, but also block and .await them. The other improvements in Rust 1.39 include shared references to by-move bindings in match guards and attributes on function parameters.

The stable version of async-await syntax

The stable async function can be utilized (by writing async fn instead of fn) to return a Future when called. A Future is a suspended computation which is used to drive a function to conclusion “by .awaiting it.” Along with async fn, the async { … } and async move { … } blocks can also be used to define async literals.

According to Nicholas D. Matsakis, a member of the release team, the first stable support of async-await kicks-off the commencement of a “Minimum Viable Product (MVP)”, as the Rust team will now try to improve the syntax by polishing and extending it for future operations.

“With this stabilization, we hope to give important crates, libraries, and the ecosystem time to prepare for async /.await, which we’ll tell you more about in the future,” states the official Rust blog.


Some of the major developments in the async ecosystem

  • The tokio runtime will be releasing a number of scheduler improvements with support to async-await syntax in this month.
  • The async-std runtime library will be releasing their first stable release in a few days.
  • The async-await support has already started to become available in higher-level web frameworks and other applications like the futures_intrusive crate.

Other improvements in Rust 1.39

Better ergonomics for match guards

In the earlier versions, Rust would disallow taking shared references to by-move bindings in the if guards of match expressions. Starting from Rust 1.39, the compiler will allow binding in the following two ways-

  • by-reference: either immutably or mutably which can be achieved through ref my_var or ref mut my_var respectively.
  • by-value: either by-copy, if the bound variable’s type implements Copy or otherwise by-move.

The Rust team hopes that this feature will give developers a smoother and consistent experience with expressions.

Attributes on function parameters

Unlike the previous versions, Rust 1.39 will enable three types of attributes on parameters of functions, closures, and function pointers.

  • Conditional compilation: cfg and cfg_attr
  • Controlling lints: allow, warn, deny, and forbid
  • Helper attributes which are used for procedural macro attributes

Many users are happy with the Rust 1.39 features and are especially excited about the stable version of async-await syntax.

A user on Hacker News comments, “Async/await lets you write non-blocking, single-threaded but highly interweaved firmware/apps in allocation-free, single-threaded environments (bare-metal programming without an OS). The abstractions around stack snapshots allow seamless coroutines and I believe will make rust pretty much the easiest low-level platform to develop for.”

Another comment read, “This is big! Turns out that syntactic support for asynchronous programming in Rust isn’t just syntactic: it enables the compiler to reason about the lifetimes in asynchronous code in a way that wasn’t possible to implement in libraries. The end result of having async/await syntax is that async code reads just like normal Rust, which definitely wasn’t the case before. This is a huge improvement in usability.”

Few have already upgraded to Rust 1.39 and shared their feedback on Twitter.

Check out the official announcement for more details. You can also read the blog on async-await for more information.

Read Next

AWS will be sponsoring the Rust Project

A Cargo vulnerability in Rust 1.25 and prior makes it ignore the package key and download a wrong dependency

Fastly announces the next-gen edge computing services available in private beta

Neo4j introduces Aura, a new cloud service to supply a flexible, reliable and developer-friendly graph database

Yubico reveals Biometric YubiKey at Microsoft Ignite