Rust editions are versioned snapshots of the language that allow new features and syntax changes without breaking existing code. You specify the edition in your Cargo.toml file under the [package] section, which tells the compiler which set of rules and keywords to apply during compilation. If omitted, the compiler defaults to the 2015 edition for backward compatibility.
[package]
name = "my-project"
version = "0.1.0"
edition = "2021"
The available editions are 2015, 2018, 2021, and 2024. Changing the edition can enable new syntax (like async/await or raw identifiers) or change how the compiler resolves paths, but it does not require recompiling dependencies that use different editions.