Rust 1.45.0 发布

文章正文
2020-07-20 04:52

首页>软件之家>软件快报

Rust 1.45.0 发布2020/7/18 7:52:10来源:开源中国作者:局长责编:懒猫

Rust 1.45.0 已发布。此版本有两个值得关注的变化:一是修复将大浮点数转换为小整数时出现的 undefined behavior 问题,官方将这种情况称为 unsoundness;二是在 expression, patterns 和 statement 中使用函数式过程宏 (procedural macros)的功能已处于稳定阶段。

修复浮点数转换为整数时的 unsoundness

对于此问题,官方的解决方案是为 as 关键字执行 "saturating cast"。下面的例子解释了什么叫 saturating cast。

上面的代码打印出

或者使用采用 unsafe 方式的新 API 进行转换:

稳定在 expression, patterns 和 statement 中使用函数式过程宏的功能

Rust 1.45.0 在三个新地方增加了调用过程宏的功能:

库变更

在 Rust 1.45.0 中,以下 API 已处于稳定阶段:

Arc::as_ptr

BTreeMap::remove_entry

Rc::as_ptr

rc::Weak::as_ptr

rc::Weak::from_raw

rc::Weak::into_raw

str::strip_prefix

str::strip_suffix

sync::Weak::as_ptr

sync::Weak::from_raw

sync::Weak::into_raw

char::UNICODE_VERSION

Span::resolved_at

Span::located_at

Span::mixed_site

unix::process::CommandExt::arg0

此外还增加了 char with ranges 来迭代代码点 (codepoint):

详情查看 https://blog.rust-lang.org/2020/07/16/Rust-1.45.0.html

分享:

下载IT之家APP,分享赚金币换豪礼

相关文章

关键词:Rust

严重安全漏洞!Rust 团队决定撤销 Crates package API

Linus Torvalds 谈 Linux 内核支持 Rust :默认可以有效启用

Rust 1.44.0 发布

TIOBE 6 月榜单:C 语言居首,Rust 首次进入前 20

Stack Overflow 2020报告出炉:Python跌至榜三,Rust最受欢迎

Rust 发行 5 周年

文章评论