Yesterday, Rust 1.31.0 and Rust 2018 was announced in the official blog of the programming language. Rust 1.31.0 is the first stable iteration of Rust 2018 and many features in this version are now stable.
Rust 2018 brings all of the work that the Rust team has been doing since 2015 to create a cohesive package. This goes beyond just language features and includes tooling, documentation, domain working groups work, and a new website.
Each Rust package can be in either Rust 2015 or Rust 2018 and they work seamlessly together. Projects made in Rust 2018 can use dependencies from 2015, and a 2015 project can use 2018 dependencies. This is done so that the ecosystem doesn't split. The new features are opt-in to preserve compatibility in existing code.
Non-lexical lifetimes or NLL simply means that the borrow checker is now smarter, and accepts some valid code that was rejected by it previously.
People new to Rust struggle with its module system. Even if there are simple and consistent rules that define the module system, their consequences can come across as inconsistent, counterintuitive and mysterious. Hence Rust 2018 introduces a few changes to how paths work. These changes ended up simplifying the module system, and now there is better clarity as to what is going on in the module system.
Some additional elision rules for impl blocks and function definitions are added. For example:
impl<'a> Reader for BufReader<'a> {
// methods go here
}
This can now be written like this:
impl Reader for BufReader<'_> {
// methods go here
}
Lifetimes still need to be defined in structs. But now no longer require as much boilerplate as before.
There are many ways to define a function in Rust.
Rust 1.31 adds a new way to qualify a function: const fn.
Tools like Cargo, Rustdoc, and Rustup have been crucial in Rust since version 1.0. In Rust 2018, a new generation of tools are ready for all users—
"tool attributes", like #[rustfmt::skip] were stabilized in Rust 1.30. In Rust 1.31, "tool lints," like #[allow(clippy::bool_comparison)] are being stabilized. These give a namespace to lints making their tool of origin more clear.
Apart from changes in the language itself, there are changes to other areas too.
Rust Survey 2018 key findings: 80% developers prefer Linux, WebAssembly growth doubles, and more
Rust Beta 2018 is here
GitHub Octoverse: The top programming languages of 2018