Rust programming language 1.36 release

Published system programming language release Rest 1.36founded 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:

  • Stabilized type (trait) Future, which represents a value that may not have finished evaluating while using async / .await blocks. Asynchronous values ​​defined with Future make it possible to continue execution in the payload thread, while waiting for the completion of calculations of a certain value;
  • Library stabilized allocA that provides smart pointers and collections for manipulating memory allocated values. Memory allocation in std now uses type Vec, which are re-exported from alloc. Separate use of alloc makes sense in applications not bound to std ("#![no_std]"), as well as in libraries designed for use in such programs without std;
  • To bypass checks for correct initialization of values proposed intermediate type MaybeUnit, which can be used in place of the mem::uninitialized function, as a safer alternative. The mem::uninitialized function is convenient for quickly creating arrays, but it confuses the compiler, as it creates the appearance of initialization, but in reality the value remains uninitialized. MaybeUninit allows you to explicitly indicate to the compiler that the value is uninitialized, take into account the possible undefined behavior associated with this, and also organize checks in programs through β€œmaybe_t:” and stage-by-stage initialization with a mark of its completion using the β€œ.assume_init ()” call. With the advent of MaybeUninit, the mem::uninitialized function has been deprecated and deprecated;
  • The NLL (Non-Lexical Lifetimes) technique, which extended the system for accounting for the lifetime of borrowed variables, is stabilized for the Rust 2015 language (initially, NLL was supported only by Rust 2018). Instead of binding lifetimes at the lexical level, NLL implements accounting at the level of a set of pointers in the flow graph. This approach allows you to increase the quality of the variable borrowing checker (borrow checker) and allow the execution of certain types of correct code, the use of which previously led to an error. The new behavior also greatly simplifies debugging;
  • Included a new implementation of associative arrays hash mapbased on the application of the structure swiss table (automatically loaded hashbrown::HashMap, unless explicitly stated otherwise, such as std::HashMap, which is based on SipHash 1-3). The software interface remains the same, and the differences noticeable to the developer come down to an increase in performance and a decrease in memory consumption;
  • To the cargo package manager added the "--offline" option, which enables the mode of operation without accessing the network, in which only packages cached in the local system are used when installing dependencies. If the dependency is not in the local cache, an error will be thrown. You can use the "cargo fetch" command to prefetch dependencies into the local cache before going offline;
  • Implemented the ability to call the macro "dbg!" with multiple arguments;
  • The "const" attribute, which determines the possibility of using in any context instead of constants, is applied to methods
    Layout::from_size_align_unchecked,
    mem::needs_drop,
    NonNull::dangling and
    NonNull::cast;

  • A new portion of the API has been transferred to the category of stable, including methods stabilized
    task::Waker, task::Poll,
    VecDeque::rotate_left, VecDeque::rotate_right,
    Read::read_vectored, Write::write_vectored,
    Iterator::copied
    BorrowMut (for strings) and str::as_mut_ptr.

Source: opennet.ru

Add a comment