Rust programming language 1.57 release

The release of the system programming language Rust 1.57, founded by the Mozilla project, but now developed under the auspices of the independent non-profit organization Rust Foundation, has been published. 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 (runtime is reduced to basic initialization and maintenance of the standard library).

Rust's automatic memory management saves the developer from errors when manipulating pointers and protects against problems that arise due to low-level memory manipulation, 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.

Main innovations:

  • Stabilized the use of the macro "panic!" in compile-time contexts, such as "const fn" declarations. Also, in addition to using "panic!" in const declarations, the use of the macro "assert!" and some other standard library APIs. Stabilization does not yet cover the entire formatting infrastructure, therefore, in its current form, the macro "panic!" can only be used with static strings (panic!("...")) or with a single interpolated "&str" value in substitution (panic!("{}", a)), which must be limited to "{}" substitution without format specifiers and other types. In the future, the applicability of macros in constant contexts will be expanded, but the stabilized features are already enough to perform assert checks at compile time: const _: () = assert!(std::mem::size_of:: () == 64); const _: () = assert!(std::mem::size_of:: () == 8);
  • The Cargo package manager allows profiles with arbitrary names, not limited to 'dev', 'release', 'test' and 'bench'. For example, to enable optimization at the stage of linking (LTO) only during the formation of the final assemblies of the product, you can create the β€œproduction” profile in Cargo.toml and add the β€œlto = true” flag to it. At the same time, when defining your own profiles, you must specify an existing profile in order to inherit the default settings from it. The example below creates a "production" profile that augments the "release" profile by including the "lto=true" flag. The profile itself is activated when calling cargo with the "-profile production" option, and the build artifacts will be placed in the "target/production" directory. [profile.production] inherits="release" lto=true
  • The use of try_reserve for Vec, String, HashMap, HashSet and VecDeque types has been stabilized, which allows you to pre-reserve space for a certain number of elements of a given type in order to reduce the frequency of memory allocation operations and avoid crashes in the process due to lack of memory.
  • It is allowed to specify macros with curly braces in expressions like "m!{ .. }.method()" and "m!{ .. }?".
  • Optimized the execution of the File::read_to_end and read_to_string functions.
  • Support for the Unicode specification has been updated to version 14.0.
  • Expanded the number of functions marked with "#[must_use]" to issue a warning if a return value is ignored, which helps catch errors caused by the assumption that a function will change values ​​rather than return a new value.
  • Added experimental backend for generating code using libgccjit.
  • A new portion of the API has been moved to the category of stable, including the methods and implementations of traits have been stabilized:
    • [T; N]::as_mut_slice
    • [T; N]::as_slice
    • collections::TryReserveError
    • HashMap::try_reserve
    • HashSet::try_reserve
    • String::try_reserve
    • String::try_reserve_exact
    • Vec::try_reserve
    • Vec::try_reserve_exact
    • VecDeque::try_reserve
    • VecDeque::try_reserve_exact
    • Iterator::map_while
    • iter::MapWhile
    • proc_macro::is_available
    • Command::get_program
    • Command::get_args
    • Command::get_envs
    • Command::get_current_dir
    • CommandArgs
    • CommandEnvs
  • The "const" attribute, which determines the possibility of using it instead of constants in any context, is used in the hint::unreachable_unchecked function.
  • Implemented level 6 support for armv3k-nintendo-7ds, armv68-unknown-linux-uclibceabihf, m64k-unknown-linux-gnu, aarch3-kmc-solid_asp7, armv3a-kmc-solid_asp7-eabi and armv3a-kmc-solid_aspXNUMX-eabihf platforms. The third level implies basic support, but without automated testing, publishing official builds and checking the ability to build the code.

Source: opennet.ru

Add a comment