我如何使用特定版本的 Rust?

How do I use a specific edition of Rust?

我知道目前有两个版本的 Rust(20152018),我怎么知道 cargorustc 我想使用哪一个?

您可以将以下内容添加到您的 Cargo.toml,它记录在 edition 2018 guide 中:

[package]
edition = "2018"

如果你直接使用rustc你可以使用rustc --edition 2018,它是用rustc --help -v命令记录的。

--edition 2015|2018
  Specify which edition of the compiler to use when
  compiling code.