Rust 1.55.0 正式发布

栏目: 软件资讯 · 发布时间: 4年前

内容简介:Rust 团队正式推出新版本的 Rust 1.55.0,如果你此前已通过 rustup 安装了以前的 Rust 版本,运行以下命令即可升级至最新版本: rustup update stable 1.55.0 稳定版中的更新内容包括: Cargo 重复编译器错误...

Rust 团队正式推出新版本的 Rust 1.55.0,如果你此前已通过 rustup 安装了以前的 Rust 版本,运行以下命令即可升级至最新版本:

rustup update stable

1.55.0 稳定版中的更新内容包括:

Cargo 重复编译器错误

在过去的版本中,当运行 cargo testcargo check --all-targets 或类似的命令在多个配置中构建相同的 Rust crate 时,错误和警告可能会重复出现,因为 rustc 的运行是并行的,而且都显示相同的警告。

例如,在 1.54.0 中,类似这样的输出很常见:

$ cargo +1.54.0 check --all-targets
    Checking foo v0.1.0
warning: function is never used: `foo`
 --> src/lib.rs:9:4
  |
9 | fn foo() {}
  |    ^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

warning: function is never used: `foo`
 --> src/lib.rs:9:4
  |
9 | fn foo() {}
  |    ^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

    Finished dev [unoptimized + debuginfo] target(s) in 0.10s

在 1.55 版本中,这一行为已被调整为在编译结束后进行重复并打印报告:

$ cargo +1.55.0 check --all-targets
    Checking foo v0.1.0
warning: function is never used: `foo`
 --> src/lib.rs:9:4
  |
9 | fn foo() {}
  |    ^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: `foo` (lib) generated 1 warning
warning: `foo` (lib test) generated 1 warning (1 duplicate)
    Finished dev [unoptimized + debuginfo] target(s) in 0.84s

更快、更准确的浮点数解析

标准库的浮点解析实现已经更新为使用 Eisel-Lemire 算法,这带来了速度的提高和正确性的改善。在过去,某些边缘情况无法解析,现在这已经被修复了。

std::io::ErrorKind 变体已更新

std::io::ErrorKind 是一个 #[non_exhaustive] 枚举,它将错误分为可移植的类别,如 NotFoundWouldBlock。拥有 std::io::Error 的 Rust 代码可以调用 kind 方法来获得 std::io::ErrorKind,并在此基础上进行匹配以处理特定错误。

并非所有的错误都被归类为 ErrorKind 值;有些错误没有被归类,而是被放置在一个万能的变体中。在以前的 Rust 版本中,未分类的错误使用 ErrorKind::Other;然而,用户创建的 std::io::Error 值也通常使用 ErrorKind::Other。在 1.55 中,未分类的错误现在使用内部变体 ErrorKind::Uncategorized;这使得 ErrorKind::Other 专门用于构造不来自标准库的 std::io::Error 值。

增加了开放范围(open range)模式

Rust 1.55 稳定了模式中开放范围的使用:

match x as u32 {
      0 => println!("zero!"),
      1.. => println!("positive number!"),
}

稳定的 API

以下方法和特性的实现被稳定化:

  • [Bound::cloned]( )
  • [Drain::as_str]( )
  • [IntoInnerError::into_error]( )
  • [IntoInnerError::into_parts]( )
  • [MaybeUninit::assume_init_mut]( )
  • [MaybeUninit::assume_init_ref]( )
  • [MaybeUninit::write]( )
  • [array::map]( )
  • [ops::ControlFlow]( )
  • [x86::_bittest]( )
  • [x86::_bittestandcomplement]( )
  • [x86::_bittestandreset]( )
  • [x86::_bittestandset]( )
  • [x86_64::_bittest64]( )
  • [x86_64::_bittestandcomplement64]( )
  • [x86_64::_bittestandreset64]( )
  • [x86_64::_bittestandset64]( )

以前稳定的函数现在是 const

  • [str::from_utf8_unchecked]( )

Rust 1.55.0 版本中的其他变化可查看:https://blog.rust-lang.org/2021/09/09/Rust-1.55.0.html


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Web Design Handbook

Web Design Handbook

Baeck, Philippe de 编 / 2009-12 / $ 22.54

This non-technical book brings together contemporary web design's latest and most original creative examples in the areas of services, media, blogs, contacts, links and jobs. It also traces the latest......一起来看看 《Web Design Handbook》 这本书的介绍吧!

html转js在线工具
html转js在线工具

html转js在线工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具