我如何使用特定版本的 Rust?
How do I use a specific edition of Rust?
我知道目前有两个版本的 Rust(2015
和 2018
),我怎么知道 cargo
和 rustc
我想使用哪一个?
您可以将以下内容添加到您的 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.
我知道目前有两个版本的 Rust(2015
和 2018
),我怎么知道 cargo
和 rustc
我想使用哪一个?
您可以将以下内容添加到您的 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.