original text ：Rust 2018 is Approaching: Managing the Transition from Rust 2015
translation ： Open source in China （oschina2013）
edit ：OSC- Darwin
If you need to reprint, please indicate the above information
Rust The core development team recently released a report saying ,Rust 2018 The first version of will be in 2018 year 12 month 6 Ready for next day , Corresponding Rust 1.31. Under the new label, it integrates self Rust 2015 A lot of new features since the first release , It further enriches the characteristics of language .
Rust 2018 Focus on the improvement of language productivity , Such as , Focus on compiler performance , Optimize language features , Further improve the tools 、 Libraries and documents, etc .Rust 2018 Some of the new features of the language have been introduced recently Rust In the release notes , It might show up in Rust 1.31 In the version before the official version , These include ：impl Trait、macros 2.0、SIMD Support , generator , Non lexical life cycle （non-lexical lifetimes）,async/await Support and module modification .
The most remarkable thing is ,Rust 2018 There will be a certain degree of relaxation to ensure its stability , For the possible destruction of existing Rust 2015 Language changes to the code provide support . for example ,Rust 2018 Will include try keyword , This may conflict with function or variable names in some code .
In order to solve this problem and other similar problems that may arise , And help developers from Rust 2015 The transition to Rust 2018,Rust Will follow C++ and Java Steps for , This includes the following meanings ：
Rust 2018 You can choose to join . If you want to use it in an existing project Rust 2018, Can be edition=‘2018’ Add to project cargo.toml in . If the version key is missing ,Rust The compiler will use... By default Rust 2015.. Use cargo new All new projects created are added by default edition=‘2018’.
because Rust The compiler will be able to support Rust 2015 and 2018, therefore Rust 2015 and Rust 2018 Project dependencies and versions of can be mixed at will , And there's no problem . That means , You will be able to go to Rust 2018 Used in program Rust 2015 Dependencies , It can also be in Rust 2015 Project use Rust 2018 Dependencies .
The language core will remain unchanged , It means Rust 2018 Will only include changes to the surface , As mentioned earlier try keyword , Or some warnings converted to errors, etc .
Besides ,Rust 2018 Will include a new tool cargo fix, It will help developers transform existing code bases , Realize the gradual conversion of code , To adopt Rust 2018 Recommended new features and idioms .
Rust The core team released earlier this month Rust 1.28： A global allocator is introduced , Allow developers to provide their own memory allocators instead of system allocators ;NonZero Numeric type , Memory optimization can be done ; Improved error message and format .