27

Rust 1.38 稳定版发布 - OSCHINA

 4 years ago
source link: https://www.oschina.net/news/110218/rust-1-38-released
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Rust 1.38 稳定版发布

发布于 2019年09月29日

Rust 1.38 已经发布了,Rust 1.38.0 稳定版内容如下:

管道编译(pipelined compilation)

如果想要编译 crate,编译器不需要完全构建依赖项,只需要它们的“元数据”(即类型、依赖项、导出的列表),元数据在编译过程早期生成。从 Rust 1.38.0 开始,Cargo 将基于这一优势,一旦元数据准备就绪,就自动开始构建依赖的 crate。

虽然这种变化对单个 crate 的编译没有任何影响,但经过测试,得到了一些报告,对于涉及多个 crate 的构建,可为干净的和优化的构建带来大约 10~20% 的编译速度 。而其他的改进并不多,速度的提高取决于运行构建的硬件。

mem::{uninitialized, zeroed}

从 1.38 开始,rustc 将为使用 mem::uninitialized 或 mem::zeroed 错误初始化的狭义类提供 lint。

#[deprecated] macros

#[deprecated] 属性最初是在 Rust 1.9.0 版本中引入的。Rust 1.38.0 扩展了属性,允许将其应用于宏,使用 deprecated 属性将宏标记为 deprecated。

std::any::type_name

对于调试,获取类型的名称有时是有用的。例如,在通用代码中,你可能希望在运行时看到函数的类型参数被实例化的具体类型,此版本可以使用 std::any::type_name 达到这一需求:

fn gen_value<T: Default>() -> T {
    println!("Initializing an instance of {}", std::any::type_name::<T>());
    Default::default()
}

fn main() {
    let _: i32 = gen_value();
    let _: String = gen_value();
}

输出结果:

Initializing an instance of i32
Initializing an instance of alloc::string::String

库的更改

  • slice::{concat,connect,join} 现在支持 &[T] 和 &T
  • *const T 和 *mut T 现在实现 maker::Unpin
  • Arc<[T]> 和 Rc<[T]> 实现 FormIterator<T>
  • iter::StepBy,Peekble,Take 实现 DoubleEndedIterator

另外,以下这些功能已经稳定:

获取 1.38 版本方式如下:

rustup update stable

详情见发布公告:

https://blog.rust-lang.org/2019/09/26/Rust-1.38.0.html


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK