Editions in Rust

  • When you use, cargo new, Rust adds a bit of metadata to your cargo.toml about edition under [package].

    edition = "2021"
    
  • Here are the details about editions:

    EditionDescription
    2015If no edition is specified, your project is using this edition.
    2018The Rust Book is written using this edition.
    2021This is the latest release at the moment.
  • Rust has a 6-week release cycle.

  • Rust releases small changes very often rather than big changes less often.

  • Every 2-3 years, Rust team releases a new edition.

  • Rust supports backward compatibility, it means even if you update your Rust software your old code will still compile.

  • Here are the following cases you may consider:

    EditionDependencyWill Compile?
    20152018:white_check_mark:
    20182015:white_check_mark:
  • For more details, the Edition Guide is a complete book about editions that enumerates the differences between editions and explains how to automatically upgrade your code to a new edition via cargo fix.