📜 ⬆️ ⬇️

Release Rust 1.22 (and 1.22.1)

The Rust team is pleased to announce two new versions of Rust: 1.22.0 and 1.22.1. Rust is a system programming language aimed at security, speed, and parallel code execution.


Wait, two versions? At the last moment we found a problem with the new macOS High Sierra in version 1.22.0 and for various reasons released version 1.22.0 as usual, but also released 1.22.1 with a fix. The bug was found in Cargo's package manager, not in rustc , and only affected macOS High Sierra users.

If you have a previous version of Rust installed, just update it with:


 $ rustup update stable 

If you have not yet installed rustup , you can install it from the corresponding page of our website. Detailed notes for the release of Rust 1.22.0 and 1.22.1 can be found on GitHub.


What is included in the stable versions 1.22.0 and 1.22.1


The most important change in this version, which many have been waiting for: now can ? with Option<T> ! About a year ago, in Rust 1.13 , we introduced the operator ? to work with Result<T, E> . Since then, there have been discussions about how far the operator is ? should come: Should it stay only for Result ? Do you allow users to expand it? Should it be used with Option<T> ?


In Rust 1.22, the main use of the operator ? with Option<T> stabilized. Now this code will be collected:


 fn try_option_some() -> Option<u8> { let val = Some(1)?; Some(val) } assert_eq!(try_option_some(), Some(1)); fn try_option_none() -> Option<u8> { let val = None?; Some(val) } assert_eq!(try_option_none(), None); 

However, this functionality is still a bit limited. For example, you cannot write code that combines Result and Option s with an operator ? in one function. This will be implemented later - the nightly version of Rust already has this feature. Expect news of this in future releases.


Types that implement Drop are const and static . For example:


 struct Foo { a: u32 } impl Drop for Foo { fn drop(&mut self) {} } const F: Foo = Foo { a : 0 }; static S: Foo = Foo { a : 0 }; 

By itself, this change is not very useful, but as our ability to execute code during assembly improves, more and more types will be available for use in const and static .


Also, some nice little things were added:


Two recent compiler changes should speed up build speed in debug mode. We do not have exact figures, but, as always, reducing assembly time remains one of our priorities.


T op= &T now works for primitive types , which is easier to show with an example:


 let mut x = 2; let y = &8; //    : x += y; 

Previously, you would have to write x += *y to dereference the link.


Backrays are improved in MacOS .


Now you can compile-fail tests in Rustdoc , for example:


 /// ```compile_fail /// let x = 5; /// x += 2; //   ! /// ``` 

We draw your attention to the fact that such tests are less reliable, since the additional features of Rust can make the previously unbuilt code work. For example, how was it with ? : the code was not collected with Rust 1.21, but now it works with Rust 1.22, causing your test to crash.


Finally, we le32-unknown-nacl . Google itself declared PNaCl obsolete in order to direct all forces to support WebAssembly . You can now assemble the Rust code in WebAssembly and you can expect news about the development of its support in new releases of Rust.


See the release notes for details.


Standard Library Stabilization


Several new APIs have been stabilized in this release:



See the release notes for details.


Cargo functionality


If you want to show a large example to users, then Cargo has the opportunity to create examples from several files by creating a subdirectory with main.rs inside examples .


Now Cargo has the possibility of local substitution (vendoring) git repositories .


See the release notes for details.


Developers 1.22.0 and 1.22.1


A lot of people participated in the development of Rust 1.22. We could not achieve this without the participation of each of you. Thank! (and thanks again! )


Authors translation: @ BORN2LOSE and ozkriff . Thank you vitvakatu for translation assistance.


')

Source: https://habr.com/ru/post/343058/


All Articles