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.
Rust editions are like version snapshots that let you opt into new language features without breaking old code. Edition 2021 is the standard for modern Rust, enabling cleaner async code and better type safety. Think of it as upgrading your car's software to get new safety features while keeping the same engine.