Array with you: Rust 1.53 lands with IntoIterator and nested Or, allows for localised code

Rust 1.53

The team behind programming language Rust has put the finishing touches on version 1.53, which is now available. The main tweak? It finally allows developers to use the Or pattern more freely and iterate over arrays by value.

Until the current release, array iterations could only be done by reference. The new release, however, fits arrays with a so-called IntoIterator trait to rectify the situation. The implementation uses a workaround to make sure older code stays intact. This is because backwards compatibility problems were the reason for not allowing iteration by value in the first place. With the introduction of the trait, devs can now also pass arrays to methods who expect a T: IntoInterator to work.

Avid Rust fans might remember that the IntoIterator was one of the topics the team touched upon while giving an overview of the changes planned for 2021 earlier this year. Another one was extended support for the Or pattern, which also lands in 1.53. Programmers can now specify the pattern using | inside pattern matches instead of on complete patterns only. 

This adjustment makes things like Some(1 | 2) work, which in turn helps in writing more compact code, since Some(1) | Some(2) had been the only option to make use of the OR pattern before. Macro rules macros that accept patterns using the :pat fragment specifier don’t match | yet, in order to keep old macros intact. This is supposed to change with the 2021 edition of the language the Rust team announced, although a :pat_param macro_rules! matcher has already been added, and can be used in cases that depend on the old behaviour.

Another language modification that can be found in Rust 1.53 allows the use of any identifier that fits the “UAX #31: Unicode Identifier and Pattern Syntax” standard. This gives developers the chance to name things and comment in their own language using familiar characters, but doesn’t go as far as allowing emoji into the code.

Library changes in Rust 1.53 include an addition to index into slices via (Bound<usize>, Bound<usize>) and some tweaks that let apps running on Android platforms provide abort messages which can be helpful when debugging. 

Meanwhile the compiler of the project has been updated to require at least LLVM 10 and comes with Tier 3 support for the wasm64-unknown-unknown target and improved debugging information for closures and async functions on Windows MSVC.

Following a more inclusive naming initiative, Rust’s package manager Cargo no longer assumes the name of the default HEAD branch to be master. Other changes in the tool say that the authors field is no longer included in the Cargo.toml for new projects and that macOS targets default to unpacked split-debuginfo.

Additional information as well as a list of the stabilised APIs included in Rust 1.53 can be found in the Rust repository.