Rust 1.45.0 发布

发布时间:2023-06-23 07:30:56 作者:doudou273 阅读量:9212

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已处于稳定阶段:

  • 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

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

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

***本网站图片,文字之类版权申明,因为网站可以由注册用户自行上传图片或文字,本网站无法鉴别所上传图片或文字的知识版权,如果侵犯,请及时通知我们,本网站将在第一时间及时删除。

我要评论

企业区
Catfish(鲶鱼) Blog V 4.7.3