Rust 1.30 to be Released

Check the new features of this Mozilla supported programming language
29 October 2018   883

The release of the system programming language Rust 1.30, developed by the Mozilla project. The language is focused on safe work with memory, provides automatic memory management and provides the means to achieve high parallelism in the execution of tasks, while doing without the use of garbage collection and runtime.

178 developers took part in the preparation of the new release. 

The creators of the language drew attention to the fact that the rules for working with modules in Rust are unintuitive and make it difficult to master the language. In version 1.30, they tried to make this system more understandable by making some changes to use.

External containers are now loaded first:

// old
let json = ::serde_json::from_str("...");
// new
let json = serde_json::from_str("...");

Thanks to this fix, when processing code, external containers will be used regardless of the module hierarchy.

In addition, use expresses objects with the help of the crate keyword:

mod foo {
    pub fn bar() {
        // ...
    }
}

// old
use ::foo::bar;
// or
use foo::bar;

// new
use crate::foo::bar;

In Rust 1.30, developers have implemented the option of creating two new types of procedural macros. Attribute-like macro allows the user to define their own attributes. It also has more flexibility in operation than user extraction, since it can be used in functions. As an example, the developers cite the code that will be used in the framework of the web application:

#[route(GET, "/")]
fn index() {

At the same time, the #[route] attribute is determined by the framework itself and may look like this:

#[proc_macro_attribute]
pub fn route(attr: TokenStream, item: TokenStream) -> TokenStream {

In this case, the macro code sql! in the program code! used as follows:

let sql = sql!(SELECT * FROM posts WHERE id=1);

The developers have added the ability to display macros in the field of view using the use. This measure helped streamline the code and eliminate the macro_use annotation.

The proc_macro container is now stable, which allows using the API for writing macros.

Since as the language developed, the set of keywords gradually changed, in Rust 1.30 it was decided to make available the use of such words as identifiers using the #r prefix.

// define a local variable named `for`
let r # for = true;

// define a function named `for`
fn r # for () {
    // ...
}

// call that function
r # for ()

The creators of Rust thought about users who work with RTL writing, so in the names of some functions the word “left” was replaced with “start”, and “right” with “end”.

Rust 1.42 to be Rolled Out

New version of Mozilla-backed programming language gives a lot of changes and improvements, for example subslice patterns
16 March 2020   167

Rust programming language received new update - version 1.42 has been published. The language is focused on safe work with memory, provides automatic memory management and provides means to achieve high concurrency of tasks, without using the garbage collector and runtime.

Some of the new features:

  • Added support for templates for matching parts of slices (dynamic arrays, slice). If exact comparisons were previously allowed, now the ability to use constructions with the label ".." to cover the remaining elements of the array has been added. For instance:
  • Added a new macro "matches!", Which accepts an expression and a template at the input, and returns "true" if the template matches the expression. The template may use operations "|" and "if".
  • Panic messages displayed when the Option and Result types are used incorrectly now show line numbers with a link to the code that made the problem call, rather than links to the call implementation code in libcore. For example, a change affects the call to unwrap and expect over Option :: None, or crashes when using unwrap_err, expect, expect_err and similar methods for the Result type.
  • Cargo package manager provides automatic substitution of "proc_macro crate" into the "extern" block for packages with procedural macros. This change allows the use directive to be applied to procedural macros without the need to specify extern crate proc_macro in the code. For example, if the program uses the string "use proc_macro :: TokenStream;", then the code will now remain working if "extern crate proc_macro;" is removed from it.
  • Extended features of the standard library. Iter :: Empty <T> added support for Send and Sync for any T. values. Calls :: :: map_unchecked, map_unchecked_mut} eliminated the need to return a type value for the implementation of "Sized". Io :: Cursor implements PartialEq and Eq. The "const" attribute, which determines whether it can be used in any context instead of constants, is used for the Layout :: new method.
  • A new portion of the API has been transferred to the category of stable, including CondVar :: wait_while, CondVar :: wait_timeout_while, DebugMap :: key, DebugMap :: value, ManuallyDrop :: take, ptr :: slice_from_raw_parts_mut and ptr :: slice_from_raw_parts.
  • The Error :: description method is deprecated.
  • Provided in the second level of support for armv7a-none-eabi and riscv64gc-unknown-linux-gnu platforms. Support for the standard library for the riscv64gc-unknown-linux-gnu platform is provided. Apple's 32-bit platforms have been downgraded to a third level of support, which implies basic support, but without automated testing and publication of official assemblies. The decrease in support level is due to the termination of support by Apple 32-bit platforms.

Get more at the official blog.