Rust 1.33 Release
- Transfer
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 enables everyone to create reliable and efficient software.
If you have a previous version of Rust installed using rustup
, then to upgrade Rust to version 1.33.0 you just need to do:
$ rustup update stable
If you have not installed it yet rustup
, you can install it from the corresponding page of our website. With detailed notes to Rust 1.33.0 release is available on GitHub.
What is included in the stable version 1.33.0
Major improvements to this release include: significant expansion of capabilities const fn
and stabilization of the new Pin API.
Empowerment const fn
const fn
can do much more now , namely:
- unconditional (irrefutable) pattern matching (e.g.
const fn foo((x, y): (u8, u8)) { ... }
) let
bindings (e.g.let x = 1;
)- mutable
let
bindings (e.g.let mut x = 1;
) - assignment expressions (for example
x = y
) and assignment operators (for examplex += y
), including assignment to projections (for example, a structure field or the result of an indexing operator -x[3] = 42
) - expression statements (e.g.
3;
)
Even you can now call the "const unsafe fn" from "the fn const" , for example:
const unsafe fn foo() -> i32 { 5 }
const fn bar() -> i32 {
unsafe { foo() }
}
Thanks to these improvements, it became possible to declare a constant a large number of functions of the standard library. They are listed below in the library section.
Pin API
This issue introduces a new mechanism into the language, introduced type std :: pin :: Pin and marker type Unpin . The main idea is described in detail in the documentation "std :: pin" of the module :
Sometimes it can be useful to prohibit the movement of an object, i.e. guarantee the immutability of its address in memory. The main scenario for using this feature is self-referencing structures, since moving such objects will lead to invalid pointers, which can lead to undefined behavior (UB).Pin
ensures that the object referenced by any type pointer
P
has a fixed location in memory, 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 go deeper into the details now (which can be found in the documentation at the link above). However, the stabilization of this API is an important event for all Rust users, because it is a key step on the way to the highly anticipated async
/ await
. The status of the remaining work in this direction can be monitored at areweasyncyet.rs .
Import as "_"
Now you can import entities as "_" . This allows you to import the implementation of the type without entering its name in the current namespace, for example:
use std::io::Read as _;
// Тут не возникнет конфликта имен:
pub trait Read {}
See the release notes for more details .
Stabilization of the standard library
Here is a list of everything that has become constant:
- The overflowing_ {add, sub, mul, shl, shr} methods of all numeric types are now constant.
- The methods rotate_left, rotate_right, and wrapping_ {add, sub, mul, shl, shr} of all numerical types are now constant.
- The is_positive and is_negative methods of all signed numeric types are now constant.
- The get method of all NonZero types is now constant.
- The methods count_ones, count_zeros, leading_zeros, trailing_zeros, swap_bytes, from_be, from_le, to_be, to_le of all numeric types are now constant.
- The Ipv4Addr :: new method is now constant.
In addition, the following APIs are stabilized:
- unix :: FileExt :: read_exact_at and unix :: FileExt :: write_all_at
- Option :: transpose and Result :: transpose
- convert :: identity
- The above pin :: Pin and marker :: Unpin
- marker :: PhantomPinned
- Vec :: resize_with and VecDeque :: resize_with
- Duration :: as_millis , Duration :: as_micros and Duration :: as_nanos
See the release notes for more details .
Cargo Enhancements
Cargo now reassembles the crate if one of its files was modified during the initial build.
See the release notes for more details .
Crates.io
As previously announced , starting with this release, crates.io will require a confirmation email address for posting crates. Starting from 2019-03-01 00:00 UTC, execution cargo publish
will fail with accounts without verified mail.
This is required to meet DMCA requirements . If you did not notice the warnings about this that cargo wrote in recent releases, go to crates.io/me to indicate and confirm your mail. This mailing address will never be published and will be used exclusively for the direct functionality of crates.io.
Developers 1.33.0
A lot of people together created Rust 1.33. We could not have completed the work without each of you. Thanks!