The Rust development team is pleased to announce the release of a new version of Rust, 1.33.0. Rust is a programming language that allows everyone to create reliable and efficient software.
If you have a previous version of Rust installed using rustup
, then to update Rust to version 1.33.0 you just need to run:
$ rustup update stable
If you have not yet installed rustup
, you can install it from the corresponding page of our website. Detailed notes on the release of Rust 1.33.0 can be found on GitHub.
The major improvements of this release are: significant expansion of const fn
capabilities and stabilization of the new Pin API.
const fn
const fn
now can do much more , namely:
const fn foo((x, y): (u8, u8)) { ... }
)let
bindings (for example, let x = 1;
)let
bindings (for example, let mut x = 1;
)x = y
) and assignment operators (for example, x += y
), including assignment to projections (for example, the structure field or the result of the indexing operator — x[3] = 42
)3;
)You can still call "const unsafe fn" from "const fn" , for example:
const unsafe fn foo() -> i32 { 5 } const fn bar() -> i32 { unsafe { foo() } }
Thanks to these improvements, it has become possible to declare a constant number of functions of the standard library. They are listed below in the library section.
This release introduces a new mechanism into the language; type std :: pin :: Pin and marker type Unpin . The main idea is described in detail in the module's "std :: pin" documentation :
Sometimes it can be useful to prevent the object from moving, i.e. guarantee the immutability of his address in memory. The main use case of this feature is self-referencing structures, since moving such objects will invalidate the pointers, which can lead to undefined behavior (UB).Pin<P>
ensures that the object referenced by any typeP
pointer has an unchanged memory location, i.e. he cannot be moved and his memory cannot be freed. Such values are called "pinned".
It is expected that this mechanism will be used mainly by the authors of the libraries, so we will not begin now to dive deeper into the details (which can be found in the documentation at the link above). However, the stabilization of this API is an important event for all users of Rust, because it is a key step towards the much awaited async
/ await
. The status of the remaining work in this direction can be monitored at areweasyncyet.rs .
You can now import entities as "_" . This allows you to import a type implementation without putting its name into the current namespace, for example:
use std::io::Read as _; // : pub trait Read {}
See the release notes for details.
Here is a list of everything that has become constant:
In addition, the following APIs have been stabilized:
See the release notes for details.
Now cargo reassembles the crate if any of its files were modified during the initial build.
See the release notes for details.
As announced earlier , starting with this release, crates.io will require confirmation of the postal address for publication of crate. Starting from 2019-03-01 00:00 UTC, the execution of cargo publish
will end with an error for accounts without confirmed mail.
This is required to comply with DMCA requirements. If you have not noticed any warnings about this that cargo has written in recent releases, go to crates.io/me to specify and confirm your mail. This e-mail address will never be published and will be used exclusively for the immediate functionality of crates.io.
Many people co-created Rust 1.33. We could not complete the work without the participation of each of you. Thank!
Source: https://habr.com/ru/post/442244/
All Articles