Rust programming language 1.40 release

Published system programming language release Rest 1.40founded by the Mozilla project. The language focuses on safe memory management, provides automatic memory management, and provides the means to achieve high job parallelism while avoiding the use of a garbage collector and runtime.

Rust's automatic memory management saves the developer from manipulating pointers and protects against problems arising from low-level memory manipulation, such as accessing a memory area after it has been freed, dereferencing null pointers, buffer overruns, etc. To distribute libraries, ensure assembly and manage dependencies, the project develops a package manager Job, which allows you to get the libraries you need for the program in one click. A repository is supported to host libraries crates.io.

All innovations:

  • Added the ability to mark structures (struct) and enumerations (enum with Variant block) using the attribute "#[non_exhaustive]", which Allows in the future, add new fields and options to declared structures and enumerations. For example, developers of modules that have structures with publicly declared fields can use "#[non_exhaustive]" to mark structures that may have new fields added in the future. Until now, in this situation, the developer was forced to choose between declaring fields privately and binding to an immutable list of fields. The new attribute removes this limitation and allows you to add new fields in the future without the risk of breaking previously compiled external code. In crate packages, when matching options in the “match” section, an explicit definition of the mask “_ => {...}” is required, covering possible future fields, otherwise an error will be displayed when adding new fields.
  • Added by the ability to call the procedural macro mac!() in a type context. For example, you can now write “type Foo = expand_to_type!(bar);” if “expand_to_type” is a procedural macro.
  • In "extern { ... }" blocks added the ability to use procedural and attribute macros, including “bang!()” macros, for example:

    macro_rules! make_item { ($name:ident) => { fn $name(); } }

    extern {
    make_item!(alpha);
    make_item!(beta);
    }

    extern "C" {
    #[my_identity_macro] fn foo();
    }

  • In macros implemented ability to generate “macro_rules!” elements. Generating "macro_rules!" possible both in function-like macros (“mac!()”) and in macros in the form of attributes (“#[mac]”).
  • In the $m:meta mapping element added support for arbitrary token enumeration values ​​(“[TOKEN_STREAM]”, “{TOKEN_STREAM}” and “(TOKEN_STREAM)”), for example:

    macro_rules! accept_meta { ($m:meta) => {} }
    accept_meta!( my::path );
    accept_meta!( my::path = "lit" );
    accept_meta!( my::path ( abc ) );
    accept_meta!( my::path [ abc ] );
    accept_meta!( my::path { abc } );

  • In Rust 2015 mode, error output is enabled for problems identified when checking the borrowing of variables (borrow checker) using the NLL (Non-Lexical Lifetimes) technique. Previously, warnings were replaced with errors when running in Rust 2018 mode.
    After the change was extended to the Rust 2015 mode, developers were able to finally escape from the old borrow checker.

    Let us recall that the verification system based on a new mechanism for taking into account the lifetime of borrowed variables made it possible to identify some problems that went unnoticed by the old verification code. Since error output for such checks could affect compatibility with previously working code, warnings were initially issued instead of errors.

  • The “const” attribute, which determines the possibility of using it in any context instead of constants, is used for the is_power_of_two function (for unsigned integers).
  • A new portion of the API has been moved to the stable category, including the todo!() macro and the slice::repeat, mem::take, BTreeMap::get_key_value, HashMap::get_key_value, methods have been stabilized.
    Option::as_deref, Option::as_deref_mut, Option::flatten, UdpSocket::peer_addr, {f32,f64}::to_be_bytes, {f32,f64}::to_le_bytes,{f32,f64}::to_ne_bytes, {f32, f64}::from_be_bytes, {f32,f64}::from_le_bytes, and {f32,f64}::from_ne_bytes.

  • In the package manager cargo
    implemented caching compiler warnings on disk. Added the option "cargo metadata" to the "cargo metadata" command--filter-platform" to show only packages bound to the specified target platform in the dependency resolution column. Added http.ssl-version configuration option to define valid TLS versions.
    Added the ability to publish the section "dev-dependencies" without specifying the "version" key.

  • The rustc compiler provides third level support for target platforms thumbv7neon-unknown-linux-musleabihf, aarch64-unknown-none-softfloat, mips64-unknown-linux-muslabi64 and mips64el-unknown-linux-muslabi64. The third level involves basic support, but without automated testing and publication of official builds.

Source: opennet.ru

Add a comment