Home Programming Languages Rust 1.36.0 releases with a stabilized ‘Future’ trait, NLL for Rust 2015,...

Rust 1.36.0 releases with a stabilized ‘Future’ trait, NLL for Rust 2015, and more

0
1836
Rusted chain
2 min read

Yesterday, the team behind Rust announced the release of Rust 1.36.0. This release brings a stabilized ‘Future’ trait, NLL for Rust 2015, stabilized Alloc crate as the core allocation and collections library, a new –offline flag for Cargo, and more.

Following are some of the updates in Rust 1.36.0:

The stabilized ‘Future’ trait

Learn Programming & Development with a Packt Subscription

A ‘Future’ in Rust represents an asynchronous value that allows a thread to continue doing useful work while it waits for the value to become available. This trait has been long-awaited by Rust developers and with this release, it has been finally stabilized.

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,” the Rust release team added.

The alloc crate is stable

The ‘std’ crate of the standard library provides types like Box<T> and OS functionality. But, the problem is it requires a global allocator and other OS capabilities. Beginning with Rust 1.36.0, the parts of std that are dependent on a global allocator will now be available in the ‘alloc’ crate and std will re-export these parts later.

Use MaybeUninit<T> instead of mem::uninitialized

Previously, the ‘mem::uninitialized’ function allowed you to bypass Rust’s memory-initialization checks by pretending to generate a value of type T without doing anything. Though the function has proven handy while lazily allocating arrays, it can be dangerous in many other scenarios as the Rust compiler just assumes that values are properly initialized.

In Rust 1.36.0, the MaybeUninit<T> type has been stabilized to solve this problem. Now, the Rust compiler will understand that it should not assume that a MaybeUninit<T> is a properly initialized T. This will enable you to do gradual initialization more safely and eventually use ‘.assume_init()’.

Non-lexical lifetimes (NLL) for Rust 2015

The Rust team introduced NLL in December last year when announcing Rust 1.31.0. It is an improvement to Rust’s static model of lifetimes to make the borrow checker smarter and more user-friendly. When it was first announced, it was only stabilized for Rust 2018. Now the team has backported it to Rust 2015 as well. In the future, we can expect all Rust editions to use NLL.

–offline support in Cargo

Previously, the Rust package manager, Cargo used to exit with an error if it needed to access the network and the network was not available. Rust 1.36.0 comes with a new flag called ‘–offline’ that makes the dependency resolution algorithm to only use locally cached dependencies, even if there might be a newer version.

These were some of the updates in Rust 1.36.0. Read the official announcement to know more in detail.

Read Next

Introducing Vector, a high-performance data router, written in Rust

Brave ad-blocker gives 69x better performance with its new engine written in Rust

Introducing PyOxidizer, an open source utility for producing standalone Python applications, written in Rust