Rust 1.67 发布

软件资讯 软件资讯 发布于 2年前 82 浏览 0 回复

Rust 团队于近日发布了 Rust 1.67.0 新版本,1.67.0 稳定版中的主要更新内容如下:

#[must_use]async fn 有效

带有 #[must_use] 注释的 async 函数现在将该属性应用于返回的 impl Future 的输出。Future 特性本身已经带有 #[must_use] 注释,所以所有实现 Future 的类型都自动 #[must_use]

在 1.67 版本中,如果输出没有以某种方式使用,编译器现在会发出警告。

#[must_use]
async fn bar() -> u32 { 0 }

async fn caller() {
    bar().await;
}

warning: unused output of future returned by `bar` that must be used
 --> src/lib.rs:5:5
  |
5 |     bar().await;
  |     ^^^^^^^^^^^
  |
  = note: `#[warn(unused_must_use)]` on by default

std::sync::mpsc 实现更新

Rust 的标准库从 1.0 之前就有一个多生产者、单消费者的通道,但在这个版本中,实现被换成了基于 crossbeam-channel。这个版本不包含 API 的变化,但新的实现修复了一些错误,提高了实现的性能和可维护性。

从这个版本开始,用户不应该注意到行为上的任何显著变化。

稳定的 API

  • [{integer}::checked_ilog]()
  • [{integer}::checked_ilog2]()
  • [{integer}::checked_ilog10]()
  • [{integer}::ilog]()
  • [{integer}::ilog2]()
  • [{integer}::ilog10]()
  • [NonZeroU*::ilog2]()
  • [NonZeroU*::ilog10]()
  • [NonZero*::BITS]()

这些 API 现在在 const 中是稳定的:

  • [char::from_u32]()
  • [char::from_digit]()
  • [char::to_digit]()
  • [core::char::from_u32]()
  • [core::char::from_digit]()

更多详情可查看:https://blog.rust-lang.org/2023/01/26/Rust-1.67.0.html



为您推荐相关文章:

  • Rust 1.68.0 现已发布
  • Rust 1.67.1 发布
  • Rust 1.68.1 发布
  • Rust 1.80.0 发布
  • Rust 1.70.0 正式发布
  • 同类文章推荐:

  • Apache bRPC 1.11.0 发布
  • VirtualBox 7.1.4 发布
  • Python 3.14.0 Alpha 1 发布
  • Elasticsearch 8.15.3 发布
  • Spring Data 2024.1.0 RC1 发布
  • DBeaver 24.2.3 发布