The Rust 2021 edition and Rust 1.56.0 stable are now available for download. Editions in Rust enable opt-in changes that have the potential to create backwards compatibility issues.
According to the Rust team, this 2021 edition of the language is small, but includes some quality of life changes.
New changes in the latest version include:
- Closures can now capture individual named field instead of having to capture the whole identified
- The IntoIterator for arrays can now iterate over items based on value instead of reference
- Or patterns in macro-rules match top level A|B
- Cargo feature resolver version 2 is now default
- TryInto, TryFrom, and FromIterator are now in scope by default
- Panic macros now expect format strings
- Syntax is being reserved for ident#, ident“…”, and ident‘…’
- Code that triggers bare_trait_objects and ellipsis_inclusive_range_patterns will now give an error
“Rust’s 2021 edition is a small but significant evolution in the language,” said Armin Ronacher, director of engineering at Sentry and a longtime Rust developer. “While on the surface it appears to be inconsequential, it is showing that Rust stays true to its determination of backward compatibility and moving at a steady pace towards a more powerful system programming language. In the 2021 edition, the language landed improvements to fallible type conversions, solved some warts (like the inability to iterate over arrays), added a new and more powerful dependency resolver, and more flexible closure capture rules.”
More information about the latest changes can be found in the release notes.