Rust 1.34.0 发布了,更新内容如下:

Language

  • 现在可以使用 #[deprecated = "reason"] 作为 #[deprecated(note = "reason")] 的简写。
  • 现在可以在 #[attr()]、#[attr[]] 和 #[attr{}] 过程宏中接收 token 流。
  • 现在可以用 extern crate self as foo; 引入 crate 根到外部 prelude。

Compiler

  • 现在可以编译成 riscv64imac-unknown-none-elf 与 riscv64gc-unknown-none-elf
  • 现在可以使用 -C linker-plugin-lto 启用链接器插件LTO优化,这允许 rustc 将 Rust 代码编译为 LLVM bitcode,从而允许 LLVM 跨 C/C++ FFI 边界执行 LTO 优化。
  • 可以编译成 powerpc64-unknown-freebsd

Libraries

  • 在 HashMap <K, V, S> 和 HashSet <T, S> 的一些基本方法中删除了 trait bound,直观体现是不再需要 Hash trait 来创建迭代器。
  • 在 BinaryHeap <T> 的一些基本方法中删除了 Ord trait bound。
  • overflowing_neg 和 wrapping_neg 方法现在是所有数字类型的 const 函数。
  • 索引 str 现在通用于实现SliceIndex <str> 的所有类型。
  • str::trim、str::trim_matches、str::trim_ {start, end} 和 str::trim_ {start, end} _matches 现在是 #[must_use],如果它们的返回类型未使用,将产生警告。
  • check_pow、saturating_pow、wrapping_pow 和 overflowing_pow 方法可用于所有数字类型。

此外还有 API 与其它杂项的更新,详细内容查看更新说明