BT

InfoQ Homepage News Rust 1.46.0 Released

Rust 1.46.0 Released

Bookmarks

The end of August brought to the growing community of rustaceans version 1.46.0 of Rust, the system programming language initially developed at Mozilla. The language recently advanced in the top twenty programming languages bracket of the TIOBE index. As Rust is released every six weeks, the number of features is compact. This release brings enhancements to the const fn writing abilities, stabilizes the #[track_caller] which promises improved error handling and multiple additions or stabilizations to the standard libraries. The entire list of features is on the GitHub page of the language.

The core language features that can be used in static contexts was extended, so from this release one can use conditional operators (if, if let, and match), loops (while, while let and loop) and bitwise operators (&& and ||) in static contexts. It is also possible to cast and coerce a slice or even use mem::transmute. Even though these language features are not new, their main benefit is in the performance space, for example during an exercise at Microsoft the bindings for Rust were 40 time faster and on par with the C++/WinRT implementation. Following the same idea, also the std::mem::forget method is now a const fn.

The rustaceans targeting Apple’s iOS or tvOS platforms have a reason to be excited about Rust 1.46: they can now use dynamic linking for Apple iOS and tvOS platforms. This is possible by allowing cdylib targets on Apple iOS and tvOS platforms.

Back in March, Rust 1.42 introduced an improved error message, even if it was still unstable. If you're writing a function like unwrap that may panic, you can put this annotation on your functions, and the default panic formatter will use its caller as the location in its error message. Now, in Rust 1.46 this was stabilized.

In relation to stability, the APIs Option::zip and vec::Drain::as_slice were stabilized in the current version. While in relation to libraries several changes occurred as well, among which String implements From<char> that allows the writing of the following construct:

fn char_to_string() -> String {
  'a'.into()
}

All non-zero integer types (NonZeroU8) now implement TryFrom for their zero-able equivalent (e.g. TryFrom<u8>) or &[T] and &mut [T] now implement PartialEq<Vec<T>>.

So, if you want to give it a try, just type rustup update stable in your command-line terminal. This will update your Rust version to the 1.46.0. If rustup is not already on your system, you can install from Rust’s page.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • Rust 1.46.0 Released - slightly misleading error in article

    by Steve Ferraro /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    The article states that: "...for example during an exercise at Microsoft it brought a 40x improvement in the Microsoft WinRT bindings for Rust in comparison to the C++ implementation".

    What the Microsoft post actually states is that "That's about 40 times faster and on par with C++/WinRT."

    So, "on par" with the C++/WinRT code after the 40x improvement, not 40x faster than it.

  • Re: Rust 1.46.0 Released - slightly misleading error in article

    by Pop Olimpiu /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Thanks Steve! Thank you for raising awareness

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.