How do I use a specific edition of Rust?

前端 未结 1 735
太阳男子
太阳男子 2021-01-19 18:25

I know there are currently two editions of Rust (2015 and 2018), how can I tell cargo and rustc which one I want to use?<

相关标签:
1条回答
  • 2021-01-19 18:51

    You can add the following to your Cargo.toml, it's documented on the edition 2018 guide:

    [package]
    edition = "2018"
    

    If you directly use rustc you can use rustc --edition 2018, it's documented with rustc --help -v command.

    --edition 2015|2018
      Specify which edition of the compiler to use when
      compiling code.
    
    0 讨论(0)
提交回复
热议问题