Rust programming language 1.39 release

Published system programming language release Rest 1.39founded 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 a new asynchronous programming syntax based on the "async" function, the async move { ... } block, and the ".await" operator, which makes it easier to write handlers that do not block the main command flow. Compared to the previously offered API for asynchronous I/O, async/.await constructs are simple to understand, highly readable, and allow you to implement complex asynchronous interactions using familiar flow control techniques based on loops, conditional statements, and exceptions.

    The Async-await syntax allows you to create functions that can pause their execution, return control to the main thread, and then resume execution from where they left off. For example, such a pause is required when processing I/O, in which other work can be done while waiting for the next piece of data to arrive. Functions and blocks defined with "async fn" and "async move" return a trait Future, which defines a deferred asynchronous computation representation. You can directly initiate a deferred calculation and obtain the result using the β€œ.await” operator. No action is performed or pre-planned until .await is called, allowing complex nested constructs to be created without additional overhead.

    async fn first_function() -> u32 { .. }
    ...
    let future = first_function();
    ...
    let result: u32 = future.await;

  • Stabilized "#![feature(bind_by_move_pattern_guards)]", allowing the use of variables with the binding type "by-move" in templates and use references to these variables in the "if" section of the expression "match". For example, the following constructions are now allowed:

    fnmain() {
    let array: Box<[u8; 4]> = Box::new([1, 2, 3, 4]);

    match array {
    nums
    if nums.iter().sum::() == 10

    => {
    drop(nums);
    }
    _ => unreachable!(),
    }
    }

  • Indication allowed attributes when defining function parameters, closures, and function pointers. Conditional compilation attributes (cfg, cfg_attr) that control diagnostics via lint (allow, warn, deny and forbid) and auxiliary macro calling attributes are supported.

    fn len(
    #[cfg(windows)] slice: &[u16], // use the parameter on Windows
    #[cfg(not(windows))] slice: &[u8], // use in other OS
    ) -> usize {
    slice.len()
    }

  • Warnings about problems identified when checking the borrowing of variables (borrow checker) using the NLL (Non-Lexical Lifetimes) technique, translated into the category of fatal errors. 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. Warnings have now been replaced with errors when running in Rust 2018 mode. In the next release, error output will also be implemented in Rust 2015 mode, which will finally get rid of the old borrow checker;
  • The β€œconst” attribute, which determines the possibility of using in any context instead of constants, is used for the functions Vec::new, String::new, LinkedList::new, str::len, [T]::len, str::as_bytes,
    abs, wrapping_abs and overflowing_abs;

  • A new portion of the API has been transferred to the category of stable, including methods stabilized
    Pin::into_inner, Instant::checked_duration_since and Instant::saturating_duration_since;

  • The cargo package manager now has the ability to use the β€œ.toml” extension for configuration files. Added preliminary support for building the standard library directly from Cargo. Added the "--workspace" flag, replacing the controversial "--all" flag. A new field has been added to the metadata "publishβ€œ, which allows you to publish dependencies by specifying a git tag and version number. Added test option "-Ztimings" to generate an HTML report of the execution times of various compilation stages.
  • In the rustc compiler, diagnostic messages include trimming the tails of code that does not fit into the terminal. Provided third level of support for target platforms
    i686-unknown-uefi and sparc64-unknown-openbsd. The third level involves basic support, but without automated testing and publication of official builds.

Source: opennet.ru

Add a comment