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
const
functions. 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 theFrom
trait. E.g.u8
now implementsFrom<NonZeroU8>
. - You can now convert a
&Option<T>
intoOption<&T>
and&mut Option<T>
intoOption<&mut T>
using theFrom
trait. - You can now multiply (
*
) atime::Duration
by au32
.
Stabilized APIs #
slice::align_to
slice::align_to_mut
slice::chunks_exact
slice::chunks_exact_mut
slice::rchunks
slice::rchunks_mut
slice::rchunks_exact
slice::rchunks_exact_mut
Option::replace