Rust 1.25 Release

Original author: The Rust Core Team
  • Transfer

The Rust team is pleased to announce the new version of Rust: 1.25.0. Rust is a system programming language aimed at security, speed and parallel code execution.

If you have a previous version of Rust installed, just upgrade:

$ rustup update stable

If you have not already installed rustup, you can install it from the corresponding page of our website. With detailed notes to Rust 1.25.0 release is available on GitHub.

What is included in the stable version 1.25.0

The last few releases have been minor, but Rust 1.25 contains a lot of
new features ! First: we upgraded LLVM from version 4 to version 6. The update
entails a number of changes, the most important of which is support for AVR.

There is a new way to use the operator use: nested groups . If you imported in this way:

use std::fs::File;
use std::io::Read;
use std::path::{Path, PathBuf};

Now you can write it like this:

// на одной строке
use std::{fs::File, io::Read, path::{Path, PathBuf}};
// в несколько строк
use std::{

This can reduce repetition and make the code more understandable.

In this release, we introduced two major changes to the documentation. First: Rust By Example is now located at ! Soon we will redirect from the old domain. We hope this draws more attention to the great resource and you get a local copy with your local documentation.

Secondly, in Rust 1.23 we talked about moving from Hoedown to pulldown-cmark. In Rust 1.25, pulldown-cmark is now the default. Finally, we removed the last part of the C code from rustdoc and now follow the CommonMark specification.

In conclusion, in RFC 1358 , an attribute was adopted #[repr(align(x))]. In Rust 1.25, it has been stabilized ! This attribute allows you to set the alignment of your structures:

struct Number(i32);
assert_eq!(std::mem::align_of::(), 4);
assert_eq!(std::mem::size_of::(), 4);
struct Align16(i32);
assert_eq!(std::mem::align_of::(), 16);
assert_eq!(std::mem::size_of::(), 16);

If you work with low-level code, then control over such “things” can be very important!

See the release notes for more details .

Stabilization of the standard library

The biggest change in libraries is . This type is similar to , but it is nonzero and covariant. This blog post is not the best place to explain the differences, but in a nutshell: ensures that it is not null. This means that it is the same size as . If you create a data structure with unsafe code, it will often be the right choice for you!std::ptr::NonNull*mut TNonNullOption>*mut TNonNull

libcoreполучила модуль timewhich contains a type Durationpreviously only available in libstd.

In addition, functions from_secsand from_millisrelated functions Durationwere written with the help of const fn, which allows you to use them for initialization Duration, in constant expressions.

See the release notes for more details .

Cargo Changes

Cargo has one important change in the command line interface: cargo newit will now by default generate an executable file instead of a library. We try to ensure that the Cargo interface is stable enough, but this is an important change and is unlikely to break the package manager.

For reference, it cargo newnow accepts two flags: --libfor creating libraries and --binfor creating binary or executable files. In the previous version of Cargo, if you do not pass a single value, then the default flag is --lib. We made this decision because each binary file (often) depends on many libraries and therefore they (libraries) are more common. However, this is not true. Each library uses many binary files. Moreover, when creating a new project, you often want it to be a program that you can run. This problem occurs not only for beginners, but even very long-standing community members said that they found this behavior unexpected. So we change it.

Similarly, the previous version of the command cargo newwas a bit stubborn in package names. In particular, if the name of your package began with rust-or ended with -rs, Cargo would rename it. The intention was that this is a package of the Rust language, and this is redundant information. However, people care a lot about the name and when faced with it, they are surprised and often upset. Therefore, we will no longer do this .

Many users love the team cargo doc- this is a way to generate documentation locally for their project. In this issue, she received a speed increase , because now she works through cargo check, rather than cargo build. Therefore, some scripts will run faster.

Also, pumping git dependencies should be faster , thanks to the use of hard links whenever possible.

See the release notes for more details .

Developers 1.25.0

A lot of people participated in the development of Rust 1.25. We could not have achieved this without each of you

Thank you !

Translated by: @ BORN2LOSE

Also popular now: