What Changed in Rust Edition 2021?

Rust Edition 2021 adds the try keyword, const generics, and better async support, configured by setting edition = "2021" in Cargo.toml.

Rust Edition 2021 introduced the try keyword, improved async/await ergonomics, and added support for const generics and let chains. To use these features, set the edition in your Cargo.toml file:

[package]
edition = "2021"

You can also update all listings in a project by running ./tools/update-editions.sh and then updating the edition value in book.toml and nostarch/book.toml under the [rust] table.