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 univariantenums. 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:
defaultis syntactically allowed before items intraitdefinitions.- Items in
impls (i.e.consts,types, andfns) may syntactically leave out their bodies in favor of;. - Bounds on associated types in
impls 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 implementsSendandSyncfor anyT.Pin::{map_unchecked, map_unchecked_mut}no longer require the return type to implementSized.io::Cursornow derivesPartialEqandEq.Layout::newis nowconst.- Added Standard Library support for
riscv64gc-unknown-linux-gnu.
Stabilized APIs
CondVar::wait_whileCondVar::wait_timeout_whileDebugMap::keyDebugMap::valueManuallyDrop::takematches!ptr::slice_from_raw_parts_mutptr::slice_from_raw_parts
Cargo
Compatibility Notes
Error::descriptionhas been deprecated, and its use will now produce a warning. It's recommended to useDisplay/to_stringinstead.