Version 1.42.0 (2020-03-12)
Language
-
You can now use the slice pattern syntax with subslices. e.g.
#![allow(unused)] fn main() { fn foo(words: &[&str]) { match words { ["Hello", "World", "!", ..] => println!("Hello World!"), ["Foo", "Bar", ..] => println!("Baz"), rest => println!("{:?}", rest), } } }
-
You can now use
#[repr(transparent)]
on univariantenum
s. Meaning that you can create an enum that has the exact layout and ABI of the type it contains. -
You can now use outer attribute procedural macros on inline modules.
-
There are some syntax-only changes:
default
is syntactically allowed before items intrait
definitions.- Items in
impl
s (i.e.const
s,type
s, andfn
s) may syntactically leave out their bodies in favor of;
. - Bounds on associated types in
impl
s are now syntactically allowed (e.g.type Foo: Ord;
). ...
(the C-variadic type) may occur syntactically directly as the type of any function parameter.
These are still rejected semantically, so you will likely receive an error but these changes can be seen and parsed by procedural macros and conditional compilation.
Compiler
- Added tier 2* support for
armv7a-none-eabi
. - Added tier 2 support for
riscv64gc-unknown-linux-gnu
. Option::{expect,unwrap}
andResult::{expect, expect_err, unwrap, unwrap_err}
now produce panic messages pointing to the location where they were called, rather thancore
's internals.
* Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.
Libraries
iter::Empty<T>
now implementsSend
andSync
for anyT
.Pin::{map_unchecked, map_unchecked_mut}
no longer require the return type to implementSized
.io::Cursor
now derivesPartialEq
andEq
.Layout::new
is nowconst
.- Added Standard Library support for
riscv64gc-unknown-linux-gnu
.
Stabilized APIs
CondVar::wait_while
CondVar::wait_timeout_while
DebugMap::key
DebugMap::value
ManuallyDrop::take
matches!
ptr::slice_from_raw_parts_mut
ptr::slice_from_raw_parts
Cargo
Compatibility Notes
Error::description
has been deprecated, and its use will now produce a warning. It's recommended to useDisplay
/to_string
instead.