Menu
New edition of Rust promises better ‘feel’

New edition of Rust promises better ‘feel’

Third edition of the Rust programming language tees up a number of small changes expected to significantly improve the developer experience.

Credit: Dreamstime

Rust 2021, the planned third edition of the Rust programming language due in October, is expected to significantly improve how Rust feels in practice, resulting from a number of small changes.

In a May 11 bulletin, the Rust 2021 edition working group cited changes including a new prelude to the standard library, which is the module containing everything automatically imported in every module. The new prelude will fix an issue in which adding a trait can subtly break code. This will be done with three additions:

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

Other changes in the works for Rust 2021 include 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.

Delving deeper, 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.

Meanwhile, two existing lints, bare-trait-objects and ellipsis-inclusive-range-patterns, will become hard errors in Rust 2021.

Plans call for Rust 2021 Edition changes to make it into Rust 1.56.0, due in October. Editions of Rust serve as a mechanism to enable the release of features that would otherwise be backward incompatible, such as adding a keyword that would invalidate variables of the same name.

Rust editions are opt-in, so existing crates do not see the changes until they explicitly migrate over to the new edition. Crates compiled in one edition will seamlessly interoperate with crates compiled in other editions. The working group seeks to make it easy to upgrade crates to a new edition.


Follow Us

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags Rust

Events

Featured

Slideshows

Channel kicks 2021 into gear as After Hours returns to Auckland

Channel kicks 2021 into gear as After Hours returns to Auckland

After Hours made a welcome return to the channel social calendar with a bumper crowd of partners, distributors and vendors descending on The Pantry at Park Hyatt in Auckland to kick-start 2021.

Channel kicks 2021 into gear as After Hours returns to Auckland
The Kiwi channel gathers for the 2020 Reseller News Women in ICT Awards

The Kiwi channel gathers for the 2020 Reseller News Women in ICT Awards

Hundreds of leaders from the New Zealand IT industry gathered at the Hilton in Auckland on 17 November to celebrate the finest female talent in the Kiwi channel and recognise the winners of the Reseller News Women in ICT Awards (WIICTA) 2020.

The Kiwi channel gathers for the 2020 Reseller News Women in ICT Awards
Show Comments