Rust programming language 1.65 release

The general-purpose programming language Rust 1.65, founded by the Mozilla project but now developed under the auspices of the independent non-profit organization Rust Foundation, has been released. The language focuses on memory safety and provides the means to achieve high job parallelism while avoiding the use of a garbage collector and runtime (runtime is reduced to basic initialization and maintenance of the standard library).

Rust's memory handling methods save the developer from errors when manipulating pointers and protect against problems that arise due to low-level memory handling, such as accessing a memory area after it has been freed, dereferencing null pointers, buffer overruns, etc. To distribute libraries, provide builds and manage dependencies, the project develops the Cargo package manager. The crates.io repository is supported for hosting libraries.

Memory safety is provided in Rust at compile time through reference checking, keeping track of object ownership, keeping track of object lifetimes (scopes), and assessing the correctness of memory access during code execution. Rust also provides protection against integer overflows, requires mandatory initialization of variable values ​​before use, handles errors better in the standard library, applies the concept of immutable references and variables by default, offers strong static typing to minimize logical errors.

Main innovations:

  • Support for Generic Associated Types (GAT) has been added, which makes it possible to create type aliases associated with another type, and allows type constructors to be associated with traits. trait Foo { type Bar<'x>; }
  • The β€œlet … else” expression is implemented, which allows you to check the pattern matching condition directly inside the β€œlet” expression and execute arbitrary code if the pattern does not match. let Ok(count) = u64::from_str(count_str) else { panic!("Can't parse integer: '{count_str}'"); };
  • It is allowed to use the break statement to exit named blocks prematurely, using the block name (label) to determine the block to terminate. let result = 'block: { do_thing(); if condition_not_met() { break 'block 1; } do_next_thing(); if condition_not_met() { break 'block 2; } do_last_thing(); 3};
  • For Linux, added the ability to save debugging information separately (split-debuginfo), previously available only for the macOS platform. Specifying the "-Csplit-debuginfo=unpacked" option will save debuginfo data in DWARF format into several separate object files with a ".dwo" extension. Specifying "-Csplit-debuginfo=packed" will create a single package in ".dwp" format that includes all the debuginfo data for the project. To integrate debuginfo directly into the .debug_* section of ELF objects, you can use the "-Csplit-debuginfo=off" option.
  • A new portion of the API has been moved to the category of stable, including the methods and implementations of traits have been stabilized:
    • std::backtrace::backtrace
    • Bound::as_ref
    • std::io::read_to_string
    • <*const T>::cast_mut
    • <*mut T>::cast_const
  • The "const" attribute, which determines the possibility of using in any context instead of constants, is used in the functions <*const T&>::offset_from and <*mut T>::offset_from
  • As part of the final stage of transferring the implementation of the LSP (Language Server Protocol) protocol to rust-analyzer, the outdated implementation of Rust Language Server (RLS) has been replaced with a stub server that issues a warning suggesting switching to using rust-analyzer.
  • When compiling, support for inline deployment of the MIR intermediate code is enabled, which speeds up the compilation of typical crate packages by 3-10%.
  • To speed up scheduled builds, the Cargo package manager provides sorting of jobs waiting in the queue.

Additionally, an interview about the use of the Rust language at Volvo for the development of components for automotive information systems can be noted. There are no plans to rewrite existing and tested code in Rust, but for new code, Rust is one of the preferred options for improving quality at a lower cost. Rust-related working groups have also been created in the automotive associations AUTOSAR (AUTomotive Open System ARchitecture) and SAE (Society of Automotive Engineers).

In addition, David Kleidermacher, VP of Engineering at Google, spoke about Rust translation of the code used in the Android platform to manage encryption keys, as well as the use of Rust in the implementation of the DNS over HTTPS protocol, in the stack for UWB- chips (Ultra-Wideband) and in the virtualization framework (Android Virtualization Framework) associated with the Tensor G2 chip. For Android, new stacks for Bluetooth and Wi-Fi are also being developed, rewritten in Rust. The general strategy is to progressively increase security, first by moving the most insecure and vital software components to Rust, and then extending to other subsystems associated with them. Last year, Rust was included in the list of languages ​​allowed for the development of the Android platform.

Source: opennet.ru

Add a comment