Rust 1.43.0

栏目: IT技术 · 发布时间: 5年前

内容简介:The Rust team is happy to announce a new version of Rust, 1.43.0. Rust is a programming language that is empowering everyone to build reliable and efficient software.If you have a previous version of Rust installed via rustup, getting Rust 1.43.0 is as eas

The Rust team is happy to announce a new version of Rust, 1.43.0. Rust is a programming language that is empowering everyone to build reliable and efficient software.

If you have a previous version of Rust installed via rustup, getting Rust 1.43.0 is as easy as:

rustup update stable

If you don't have it already, you can get rustup from the appropriate page on our website, and check out the detailed release notes for 1.43.0 on GitHub.

What's in 1.43.0 stable

This release is fairly minor. There are no new major features. We have some new stabilized APIs, some compiler performance improvements, and a small macro-related feature. See the detailed release notes to learn about other changes not covered by this post.

item fragments

In macros, you can use item fragments to interpolate items into the body of traits, impls, and extern blocks. For example:

macro_rules! mac_trait {
    ($i:item) => {
        trait T { $i }
    }
}
mac_trait! {
    fn foo() {}
}

This will generate:

trait T {
    fn foo() {}
}

Type inference around primitives

The type inference around primitives, references, and binary operations was improved. A code sample makes this easier to understand: this code fails to compile on Rust 1.42, but compiles in Rust 1.43.

let n: f32 = 0.0 + &0.0;

In Rust 1.42, you would get an error that would say "hey, I don't know how to add an f64 and an &f64 with a result of f32 ." The algorithm now correctly decides that both 0.0 and &0.0 should be f32 s instead.

New Cargo environment variable for tests

In a move to help integration testing, Cargo will set some new environment variables .

This is easiest to explain by example: let's say we're working on a command line project, simply named "cli". If we're writing an integration test, we want to invoke that cli binary and see what it does. When running tests and benchmarks, Cargo will set an environment variable named CARGO_BIN_EXE_cli , and I can use it inside my test:

let exe = env!("CARGO_BIN_EXE_cli");

This makes it easier to invoke cli , as we now have a path to it directly.

Library changes

You can now use associated constants on floats and integers directly , rather than having to import the module. That is, you can now write u32::MAX or f32::NAN with no use std::u32; or use std::f32; .

There is a new primitive module that re-exports Rust's primitive types. This can be useful when you're writing a macro and want to make sure that the types aren't shadowed.

Additionally, we stabilized six new APIs:

Other changes

There are other changes in the Rust 1.43.0 release: check out what changed in Rust , Cargo , and Clippy .

Contributors to 1.43.0

Many people came together to create Rust 1.43.0. We couldn't have done it without all of you.Thanks!


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

查看所有标签

猜你喜欢:

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

计算复杂性

计算复杂性

阿罗拉 巴拉克 / 骆吉洲 / 机械工业出版社 / 2016-1-1 / 129元

《计算复杂性的现代方法》是一部将所有有关复杂度知识理论集于一体的教程。将最新进展和经典结果结合起来,是一部很难得的研究生入门级教程。既是相关科研人员的一部很好的参考书,也是自学人员很难得的一本很好自学教程。本书一开始引入该领域的最基本知识,然后逐步深入,介绍更多深层次的结果,每章末都附有练习。对复杂度感兴趣的人士,物理学家,数学家以及科研人员这本书都是相当受益。一起来看看 《计算复杂性》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具