Rust 1.67 发布

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

猜你喜欢

转载自www.oschina.net/news/226138/rust-1-67-released