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.