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

修复浮点数转换为整数时的unsoundness
对于此问题,官方的解决方案是为 as 关键字执行 "saturating cast"。下面的例子解释了什么叫 saturating cast。

上面的代码打印出

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

稳定在 expression, patterns 和 statement 中使用函数式过程宏的功能
Rust 1.45.0 在三个新地方增加了调用过程宏的功能:

库变更
在 Rust 1.45.0 中,以下 API已处于稳定阶段:
此外还增加了 charwith ranges来迭代代码点 (codepoint):

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