Rust editions are versioned snapshots of the language that allow the compiler to adopt new features and syntax without breaking existing code. You specify the edition in your Cargo.toml file under the [package] section to control which language rules apply to your project.
[package]
name = "my-project"
version = "0.1.0"
edition = "2021"
The available editions are 2015, 2018, 2021, and 2024, with 2021 being the current stable default and 2024 introducing further improvements.