days
-6
-3
hours
-2
0
minutes
-1
-1
seconds
-2
-4
search
Await no more!

Rust 1.39.0 stable update adds async-await

Sarah Schlothauer
rust
© Shutterstock / Tanitka

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.

Rust 1.39.0 stable is here, bringing changes to the language as well some updates for 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?

Fastest growing languages. Source: State of the Octoverse 2019

Async I/O

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.

What is async-await? You may already know how it works in languages such as C#, Dart, Kotlin, or JavaScript.

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, useasync fn syntax instead of just fnasync fn returns a Future. , which is waiting to run on an executor.

To execute Future, you use .await .

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.

Allowing attributes on function parameters

This addition makes it possible to add outer attributes on parameters of functions, closures, and function pointer types.

SEE ALSO: Top programming languages for November 2019: C gets an A+

According to the 1.39.0 release notes, these attributes include conditional compilation ( cfgcfg_attr) and controlling lints (allowwarndenyforbid).

See the original pull request for more information.

Standard library changes

From the version 1.39.0 announcement blog, the following are now  const fn:

Cargo changes

The Rust package manager receives a few updates.

SEE ALSO: Cloud systems engineers & cloud architects most in-demand roles

  • Configuration files can use the .toml filename extension
  • Support for building the standard library directly from Cargo added in Nightly
  • Added the --workspace flag as an alias for --all
  • Added publish field to to cargo metadata
  • New -Ztimings feature generates a report on how time spent has been spent on compilation steps. For Nightly only.
  • Cross-compile doctests ability added for Nightly

Miscellaneous 1.39.0 changes

Author
Sarah Schlothauer

Sarah Schlothauer

All Posts by Sarah Schlothauer

Sarah Schlothauer is an assistant editor for JAXenter.com. She received her Bachelor's degree from Monmouth University and is currently enrolled at Goethe University in Frankfurt, Germany where she is working on her Masters. She lives in Frankfurt with her husband and cat. She is also the editor for Conditio Humana, an online magazine about ethics, AI, and technology.

Leave a Reply

Be the First to Comment!

avatar
400
  Subscribe  
Notify of