Rust programming language 1.34 release

Took place system programming language release Rest 1.34developed 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 tools to the Cargo package manager to work with alternative package registries that can coexist with the crates.io public registry. For example, private application developers can now use their own private registry that can be used when listing dependencies in Cargo.toml and use a versioning model similar to crates.io for their products, as well as reference both crates.io and crates.io in dependencies. to your own registry.

    To add external registries to .cargo/config (located in $HOME or package directory)
    provided for β€œ[registries]” section, and to use an external registry, the β€œregistry” option appeared in the description of each dependency in Cargo.toml. To connect to an additional registry, just place the authentication token in the ~/.cargo/credentials file and run the command
    "cargo login --registry=my-registry", and to publish the package -
    "cargo publish --registry=my-registry";

  • Added full support for using the "?" in tests doctests, allowing you to use the code of examples from the documentation as tests. Previously operator
    "?" could be used to handle errors during test execution only if there was a "fn main()" function or in the "#[test]" functions;

  • In custom attributes defined with procedural macros provided the ability to use arbitrary sets of tokens ("#[attr($tokens)]", "#[attr[$tokens]] and #[attr{$tokens}]"). Previously, elements could only be specified in tree/recursive form using string literals, such as "#[foo(bar, baz(quux, foo = "bar"))]", but now it is possible to use enums ('#[range(0. .10)]') and constructions like "#[bound(T: MyTrait)]";
  • Stabilized traits (trait) TryFrom ΠΈ tryinto, which allow you to perform type conversions with error handling. For example, methods like from_be_bytes with integer types use arrays as input, but the data is often of type Slice, and converting between arrays and slices is problematic to do manually. With the new traits, this operation can be performed on the fly by calling .try_into(), for example, "let num = u32::from_be_bytes(slice.try_into()?)". Error type added for conversions that always succeed (e.g. from type u8 to u32) infallible, allowing you to transparently use
    TryFrom for all existing "From" implementations;

  • Function deprecated CommandExt::before_exec, which allowed a handler to be executed before running an exec that ran in the context of the child process forked after the fork() call. Under such conditions, some resources of the parent process, such as file descriptors and mapped memory areas, could be duplicated, which could lead to undefined behavior and incorrect work of libraries.
    It is recommended to use the unsafe function instead of before_exec CommandExt::pre_exec.

  • Signed and unsigned atomic integer types from 8 to 64 bits are stabilized (for example, AtomicU8), as well as signed types NonZeroI[8|16|32|64|128].
  • A new portion of the API has been moved to the category of stable, including the methods Any::type_id, Error::type_id, slice::sort_by_cached_key, str::escape_*, str::split_ascii_whitespace, Instant::checked_[add|sub] and SystemTime are stabilized ::checked_[add|sub]. The iter::from_fn and iter::successors functions have been stabilized;
  • For all integer types, the checked_pow, saturating_pow, wrapping_pow, and overflowing_pow methods are implemented;
  • Added the ability to enable optimizations at the linking stage by specifying the "-C linker-plugin-lto" build option.

Source: opennet.ru

Add a comment