Rust versions / 1.31
Rust release · Dec 6, 2018
Rust 1.31: what's new, what was stabilized
Short answerRust 1.31 was released on Dec 6, 2018: the Rust 2018 edition; 9 newly stable APIs (slice::align_to, slice::align_to_mut, slice::chunks_exact, slice::chunks_exact_mut, ...). Point release: 1.31.1 (Dec 20, 2018).
← Rust 1.30All versionsRust 1.32 →
9 APIs stabilized
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
Can it break my build?
No compatibility notes were listed for this release.
Use it
rustup update stable # get the newest release
rustup install 1.31 # or exactly this one
rustup override set 1.31 # pin a project to itTo require at least this version from users of your crate, set rust-version = "1.31" under [package] in Cargo.toml. Cargo then refuses to build it on older compilers with a clear message, and with resolver 3 (the default on the 2024 edition, Rust 1.85+) it also prefers dependency versions that support it.
Full release notes
Language
- 🎉 [This version marks the release of the 2018 edition of Rust.][54057] 🎉
- [New lifetime elision rules now allow for eliding lifetimes in functions and impl headers.][54778] 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.][54835] These are currently a strict minimal subset of the [const fn RFC][RFC-911]. Refer to the [language reference][const-reference] for what exactly is available. - [You can now use tool lints, which allow you to scope lints from external tools using attributes.][54870] 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.][54451] - [You can now use parentheses in pattern matches.][54497]
Compiler
- [Updated musl to 1.1.20][54430]
Libraries
- [You can now convert
num::NonZero*types to their raw equivalents using theFromtrait.][54240] E.g.u8now implementsFrom<NonZeroU8>. - [You can now convert a
&Option<T>intoOption<&T>and&mut Option<T>intoOption<&mut T>using theFromtrait.][53218] - [You can now multiply (
*) atime::Durationby au32.][52813]
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]
Cargo
- Cargo will now download crates in parallel using HTTP/2.
- You can now rename packages in your Cargo.toml We have a guide on how to use the
packagekey in your dependencies.
1.31.1 (Dec 20, 2018)
Release notes from the Rust project's RELEASES.md (MIT or Apache-2.0); summaries above are ours.
Up next
Next releaseRust 1.32Released Jan 17, 2019.Read it next →Also worth your time
Did this answer your question?