Rust programming language 1.77 release

The general-purpose programming language Rust 1.77, founded by the Mozilla project but now developed under the auspices of the independent non-profit organization Rust Foundation, has been released. The language focuses on memory safety 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 memory handling methods save the developer from errors when manipulating pointers and protect against problems that arise due to low-level memory handling, 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.

Memory safety is provided in Rust at compile time through reference checking, keeping track of object ownership, keeping track of object lifetimes (scopes), and assessing the correctness of memory access during code execution. Rust also provides protection against integer overflows, requires mandatory initialization of variable values ​​before use, handles errors better in the standard library, applies the concept of immutable references and variables by default, offers strong static typing to minimize logical errors.

Main innovations:

  • Added support for literals for C-strings (c"text"), which are stored in memory with a null-terminated character and are associated with the type "CStr". It is expected that C-string support will simplify writing code that interacts with layers in programming languages ​​that use null-terminated strings, and will allow necessary checks to be performed at the compilation stage. const HELLO: &core::ffi::CStr = c"Hello, world!";
  • In asynchronously executed functions declared using the expression “async fn”, the use of recursion is allowed, i.e. such functions can now call themselves. async fn fib(n: u32) -> u32 { match n { 0 | 1 => 1, _ => Box::pin(fib(n-1)).await + Box::pin(fib(n-2)).await } }
  • The offset_of! macro has been stabilized, allowing you to determine the byte offset of the fields of structures, enumerations, unions and tuples, relative to the beginning of the type. In practice, a macro can be useful in situations where you need to work at the field offset level in the absence of an instance of the type. In particular, offset_of functionality is needed when developing low-level components such as drivers. use std::mem; #[repr(C)] struct FieldStruct { first: u8, second: u16, third: u8 } assert_eq!(mem::offset_of!(FieldStruct, first), 0); assert_eq!(mem::offset_of!(FieldStruct, second), 2); assert_eq!(mem::offset_of!(FieldStruct, third), 4);
  • In the Cargo package manager, in release profiles, cleaning of files from debugging data is enabled by default (strip = “debuginfo”), unless debug mode is explicitly enabled in the Cargo profile, i.e. if parameter debug = 0.
  • The "-Zthir-unsafeck=on" option is enabled by default, providing an unsafe check for the THIR (Typed High-Level Intermediate Representation).
  • Added lint check for static_mut_refs to display a warning when using references to mutable static values.
  • The ability to use the “From<&[T;” type has been implemented. N]>" for type "Cow<[T]>". fn foo(data: impl Into >) { /* … */ } fn main() { foo(&[“hello”, “world”]); }
  • The compiler provides alignment of the 16-byte i128 and u128 types for x86 systems.
  • A new portion of the API has been moved to the category of stable, including the methods and implementations of traits have been stabilized:
    • array::each_ref
    • array::each_mut
    • core::net
    • f32::round_ties_even
    • f64::round_ties_even
    • mem::offset_of!
    • slice::first_chunk
    • slice::first_chunk_mut
    • slice::split_first_chunk
    • slice::split_first_chunk_mut
    • slice::last_chunk
    • slice::last_chunk_mut
    • slice::split_last_chunk
    • slice::split_last_chunk_mut
    • slice::chunk_by
    • slice::chunk_by_mut
    • Bound::map
    • File::create_new
    • Mutex::clear_poison
    • RwLock::clear_poison
  • The third level of support has been implemented for the aarch64-unknown-illumos, hexagon-unknown-none-elf, riscv32imafc-esp-espidf and riscv32im-risc0-zkvm-elf platforms. The third level involves basic support, but without automated testing, publishing official builds, or checking whether the code can be built.

Source: opennet.ru

Buy reliable hosting for sites with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster