[英]How do I specify the edition to use when compiling code using rustc?
我想使用rustc
編譯一個用 Rust 2018 編寫的項目,但我不知道如何從默認版本切換編譯器。 rustc
的聯機幫助頁沒有提及版本,並且內置屬性似乎也不包含任何相關內容。 我正在使用今年早些時候構建的 Debian 版本的 rustc (1.58.1),因此它應該支持所有三個版本。
我需要做什么才能讓rustc
將我的代碼視為 Rust '18?
至少在 Debian 上,Rust 附帶的手冊頁是不完整的。 將--help
傳遞給rustc
表明要設置的相關標志是--edition
:
Usage: rustc [OPTIONS] INPUT
Options:
-h, --help Display this message
--cfg SPEC Configure the compilation environment
[...]
--edition 2015|2018|2021
Specify which edition of the compiler to use when
compiling code.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.