|Rust 1.46 Adds New APIs|
|Written by Kay Ewbank|
|Thursday, 03 September 2020|
Rust has been updated with a new version that has two new APIs alongside improvements to const fn. The new release coincides with details from the Rust core team on how it sees Rust developing in the future.
Rust was designed to offer a safe, fast and concurrent language without having a garbage collector. To achieve this, it is constructed so that problems are detected at compile time meaning it can be safely used for systems programming. Rust was originally sponsored by Mozilla, and is intended for use in situations including embedding in other languages, writing programs with specific space and time requirements, and writing low-level code, like device drivers and operating systems.
The improvements to const fn extend the core language features you can use in a const fn. The list includes if, if let, and match, as well as while, while let, and loop. You can also now use the && and || operators in a const fn, and you can also cast to a slice. The developers say that while the use of all these was possible outside of const fn, they add a lot of compile-time computation power. As an example, the const-sha1 crate can let you compute SHA-1 hashes at compile time. This led to a 40x performance improvement in Microsoft's WinRT bindings for Rust.
Another improvement is linked to the better error messages introduced in the March release of Rust. These caused unwrap and related functions to panic, and the implementation wasn't stable. Rust 1.46 stabilizes this feature. If you're writing a function like unwrap that may panic, you can now add an attribute called #[track_caller] that will be used by the default panic formatter as the location in its error message.
Two new APIs were stabilized this release - :Option::zip has been expanded to be able to zip multiple items, and vec::Drain::as_slice which returns the remaining items of this iterator as a slice.
The new release was made soon after the announcement by the Rust Core Team and Mozilla of plans to create a Rust Foundation. The Rust Core Team's goal is to have the first iteration of the foundation up and running by the end of the year. Prior to this, Mozilla had announced plans to restructure the company and to lay off around 250 people, including active members of the Rust project and the Rust community.
or email your comment to: email@example.com