Creating a new project

When you create a new project with Cargo, it will automatically addconfiguration for the latest edition:

  1. > cargo +nightly new foo
  2. Created binary (application) `foo` project
  3. > cat .\foo\Cargo.toml
  4. [package]
  5. name = "foo"
  6. version = "0.1.0"
  7. authors = ["your name <you@example.com>"]
  8. edition = "2018"
  9. [dependencies]

That edition = "2018" setting will configure your package to use Rust 2018.No more configuration needed!

If you'd prefer to use an older edition, you can change the value in thatkey, for example:

  1. [package]
  2. name = "foo"
  3. version = "0.1.0"
  4. authors = ["your name <you@example.com>"]
  5. edition = "2015"
  6. [dependencies]

This will build your package in Rust 2015.