1.31.0 #
- Released on: 6 December, 2018
- Branched from master on: 19 October, 2018
Language #
- 🎉 This version marks the release of the 2018 edition of Rust. 🎉
- New lifetime elision rules now allow for eliding lifetimes in functions and
impl headers. E.g.
impl<'a> Reader for BufReader<'a> {}can now beimpl Reader for BufReader<'_> {}. Lifetimes are still required to be defined in structs. - You can now define and use
constfunctions. These are currently a strict minimal subset of the const fn RFC. Refer to the language reference for what exactly is available. - You can now use tool lints, which allow you to scope lints from external
tools using attributes. E.g.
#[allow(clippy::filter_map)]. #[no_mangle]and#[export_name]attributes can now be located anywhere in a crate, not just in exported functions.- You can now use parentheses in pattern matches.
Compiler #
Libraries #
- You can now convert
num::NonZero*types to their raw equivalents using theFromtrait. E.g.u8now implementsFrom<NonZeroU8>. - You can now convert a
&Option<T>intoOption<&T>and&mut Option<T>intoOption<&mut T>using theFromtrait. - You can now multiply (
*) atime::Durationby au32.
Stabilized APIs #
slice::align_toslice::align_to_mutslice::chunks_exactslice::chunks_exact_mutslice::rchunksslice::rchunks_mutslice::rchunks_exactslice::rchunks_exact_mutOption::replace