Rust 2021 Edition Promises to Improve Developer Experience

Progamming May 18, 2021

Rust 2021 Edition – the third edition of the Rust Programming Language is going to be released in October this year. The aim of this update is to significantly improve how Rust will feel in the hands of the developer while coding in Rust – resulting in several small yet very useful chances to the programming language overall.

In the May 11th Blog Post on the Rust Official Blog, the Rust 2021 Edition Developers are citing changes including a new prelude to the standard library, which is the module containing everything automatically imported in every module. The new introduction of these changes will fix an issue in which adding a trait can subtly break code. The This includes the following three new additions to the programming language.

Also in the Rust 2021 Edition, the new feature resolver that was introduced in Rust 1.51 in March will become the new default. The resolver no longer merges all requested features for crates that are depended on in multiple ways.

Other Important Changes

  • Closures, anonymous functions that can automatically capture anything referred to from within their body, will only capture the fields they use. This resolves a programming issue involving the availability of structs.
  • The panic! () macro will be more consistent, no longer accepting arbitrary expressions as the only argument.
  • To make space for new syntax in the future, syntax will be reserved for prefixed identifiers and literals, including prefix#identifier, prefix"string", prefix'c', and prefix#123, where prefix can be any identifier. Future prefixes might include f"" as a shorthand for a format string, and c"" or z"" for null-terminated C strings. Another possibility is k"keyword, to allow writing keywords that do not exist yet.
  • Two existing lints, bare-trait-objects and ellipsis-inclusive-range-patterns, will become hard errors in Rust 2021.

The current plans for the Rust 2021 Edition changes mean it should make it into Rust 1.56.0, which is due to be released in October. Editions of Rust serve as a useful mechanism to enable the release of features that would otherwise be backward incompatible – such as adding a keyword that could invalidate variables of the same name in older versions of the Rust Programming Language.

The new Rust Edition are opt-in right now, so existing crates will not see the changes until they migrate over to the new edition. Crates compiled in one edition will seamlessly interoperate with crates compiled in other editions. The developers seeks to make it easier to upgrade crates to a new edition.


Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.