Rust programming language 1.38 release

Published system programming language release Rest 1.38founded 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 pipelined compilation mode (pipelined), in which the assembly of the dependent crate package starts as soon as the dependency metadata becomes available, without waiting for its compilation to complete. When you compile a package, you don't need to fully build the dependencies, just define metadata that includes lists of types, dependencies, and exports. Metadata is made available early in the compilation process, so related packages can now start compiling much earlier. When building single packages, the proposed mode does not affect performance, but if the build includes packages with branched dependencies, the total build time can be reduced by 10-20%;
  • Detection of incorrect application of functions is provided std::mem::uninitialized ΠΈ std::mem::zeroed. For example, std::mem::uninitialized is convenient for quickly creating arrays, but it confuses the compiler, as it makes it appear that initialization is being performed, but in reality the value remains uninitialized. The mem::uninitialized function is already marked as deprecated and it is recommended to use an intermediate type instead MaybeUnit. As for mem::zeroed, this function can lead to problems with types that cannot take zero values.

    A lint check has been added to the compiler to check for called undefined behavior in the new release to detect some issues with mem::uninitialized or mem::zeroed. For example, an error is now thrown when trying to use mem::uninitialized or mem::zeroed with &T and Boxβ€ΉTβ€Ί, which represent pointer objects that cannot be null;

  • The "#[deprecated]" attribute has been extended to mark crate packages as deprecated and slated for deprecation in the future. As of Rust 1.38, this attribute can also be applied to macros;
  • Added the ability to apply the "#[global_allocator]" attribute in submodules;
  • Feature added std::any::type_name, which allows you to find out the name of the type, which can be useful for debugging purposes. For example, during the execution of the program, you can find out for which type the function was called:

    fn gen_valueβ€ΉT: Default>() -β€Ί T {
    println!("Initializing an instance of {}", std::any::type_name::β€ΉTβ€Ί());
    Default::default()
    }

    fnmain() {
    let _: i32 = gen_value(); # will print "i32"
    let _: String = gen_value(); # will print "alloc::string::String"
    }

  • Extended functions of the standard library:
    • slice::{concat, connect, join} can now take a &[T] value in addition to &T;
    • "*const T" and "*mut T" now implement marker::Unpin;
    • "Arcβ€Ή[T]β€Ί" and "Rcβ€Ή[T]β€Ί" now implement FromIteratorβ€ΉTβ€Ί;
    • iter::{StepBy, Peekable, Take} now implement DoubleEndedIterator.
    • ascii::EscapeDefault implements Clone and Display.
  • A new portion of the API has been transferred to the category of stable, including methods stabilized
    • β€Ή*const Tβ€Ί::cast, β€Ή*mut Tβ€Ί::cast,
    • Duration::as_secs_f{32|64},
    • Duration::div_duration_f{32|64},
    • Duration::div_f{32|64},
    • Duration::from_secs_f{32|64},
    • Duration::mul_f{32|64},
    • division operations with remainder
      div_euclid and rem_euclid for all integer primitives;

  • Added support to the cargo package manager for specifying the "--features" option multiple times to enable different features;
  • The compiler provides a third level support for aarch64-uwp-windows-msvc, i686-uwp-windows-gnu, i686-uwp-windows-msvc, x86_64-uwp-windows-gnu, x86_64-uwp-windows-msvc targets, armv7-unknown-linux targets -gnueabi, armv7-unknown-linux-musleabi, hexagon-unknown-linux-musl and riscv32i-unknown-none-elf. The third level implies basic support, but without automated testing and publication of official builds.

Source: opennet.ru

Add a comment