Rust 1.42.0 现已发布,该版本的亮点包括:unwrap
ping 时更有用的紧急消息、分段模式、弃用Error::description
等等。具体更新内容如下:
Language
#[repr(transparent)]
,这意味着其可以创建一个枚举,该枚举具有其所包含类型的确切布局和 ABI。;
.type Foo: Ord;
)。...
(C 变量类型)可以在语法上直接作为任何函数参数的类型出现。这些仍然在语义上被拒绝,因此用户可能会收到一个错误,但是这些更改可以通过过程宏和条件编译来查看和解析。
Compiler
armv7a-none-eabi
riscv64gc-unknown-linux-gnu
Option::{expect,unwrap}
和Result::{expect, expect_err, unwrap, unwrap_err}
现在会产生紧急消息,这些消息指向被调用的位置,而不是内核的内部。Libraries
iter::Empty<T>
现在为任何 T
实现发送和同步。Pin::{map_unchecked, map_unchecked_mut}
不再需要返回类型来实现 Sized。io::Cursor
现在 derives PartialEq
和 Eq
Layout::new
现在是 const
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
相容性说明
Error::description
已被弃用,现在将产生警告。建议使用Display
/ to_string
代替。更多详细信息可查看发布说明: https://blog.rust-lang.org/2020/03/12/Rust-1.42.htm
(文/开源中国)