We are pleased to introduce the new version of Rust - 1.8. Rust is a system programming language aimed at safe work with memory, speed and parallel code execution.
As usual, you can install Rust 1.8 from the corresponding page of the official site, as well as see a detailed list of changes in this version on GitHub. This release included about 1400 patches.
The release includes two new features, and we also have good news for Windows users! Also, work continues on replacing make
in our build system with Cargo.
')
First, various compound assignment operators, such as +=
and -=
, can now be overloaded through the corresponding traits. This change was the result of RFC 953 and is as follows:
use std::ops::AddAssign; #[derive(Debug)] struct Count { value: i32, } impl AddAssign for Count { fn add_assign(&mut self, other: Count) { self.value += other.value; } } fn main() { let mut c1 = Count { value: 1 }; let c2 = Count { value: 5 }; c1 += c2; println!("{:?}", c1); }
This code will print Count { value: 6 }
. Like other treit operators, associated types allow different types to be used on both sides of an operator. See the RFC for details.
The second option is much simpler and is the result of RFC 218 . Prior to version 1.8 in Rust, structures with no data could not use curly braces:
struct Foo; // struct Bar { } //
From now on, the second option does not lead to an error. Initially, it was forbidden for consistency with other "empty declarations" and the uniqueness of parsing. However, in the following for 1.0 versions of Rust, the problem of ambiguity was solved, and the authors of macros faced additional difficulties due to the need to support both cases. In addition, with active development, it is periodically necessary to move from empty structures to non-empty and vice versa, which leads to additional work and complicates the perception of changes in patches.
Stack promotion was implemented for 32-bit MSVC builds. This translates the i686-pc-windows-msvc
into the category of mainstream platforms.
We used make
to build Rust for a long time, while we have an amazing tool for building programs on Rust - Cargo. In version 1.8, the initial support for the new build system appeared, which is written in Rust and uses Cargo as the basis. This system is not yet used by default, and there is still a lot of work to be done. We'll let you know when it comes to an end, but for now, if you are interested in the details, have a look at GitHub.
In version 1.8, about 20 functions and methods were stabilized, which can be divided into three main groups: support for UTF-16, various functions for working with time, and additional traits for the operator overload mentioned above.
Several improvements have been made:
cargo init
to initialize the Cargo-project in the current directory instead of creating a new subdirectory with the cargo new
command.cargo metadata
command has been added to receive information about the project..cargo/config
you can now specify the keys for -v
and --color
.For more information, see the complete list of changes .
In the release of version 1.8, 126 people participated. Thank you very much!
Source: https://habr.com/ru/post/281152/
All Articles