The release of the general-purpose programming language Rust 1.88 has been published. Initially developed by Mozilla, it is now being maintained by the independent non-profit organization Rust Foundation. The language focuses on safe memory management and provides tools for achieving high task parallelism without using garbage collection and runtime (runtime is limited to basic initialization and maintenance of the standard library).
The memory management methods in Rust relieve developers from errors when manipulating pointers and protect against issues arising from low-level memory operations, such as accessing memory after it has been freed, dereferencing null pointers, buffer overflows, and so on. For distributing libraries, ensuring builds, and managing project dependencies, the package manager Cargo is being developed. A repository at crates.io supports library hosting.
Safe memory handling in Rust is ensured at compile time through reference checking, ownership tracking of objects, lifetime consideration (scope) of objects, and assessment of memory access correctness during code execution. Rust also provides means to protect against integer overflows, mandates the initialization of variable values before use, improved error handling in the standard library, employs the concept of immutability for references and variables by default, and offers strong static typing to minimize logical errors.
Key innovations:
- The ability to specify multiple 'let' expressions within 'if' and 'while' conditional blocks has been added, using the '&&' (logical AND) operator for their conjunction. 'Let' expressions can be combined with boolean conditionals. Variables declared in let-expressions can be used in subsequent conditional statements, as well as inside 'if' and 'while' blocks. if let Channel::Stable(v) = release_info() && let Semver { major, minor, .. } = v && major == 1 && minor == 88 {
- Support has been added for writing 'naked' functions, marked with the attribute '#[unsafe(naked)]' and containing a single call to 'naked_asm!'. Functions created this way do not have the prologue and epilogue generated by the compiler, thus allowing the developer complete control over the assembly code attached to the function ('naked' functions contain only the assembly instructions specified by the developer and do not include the special argument and return value handlers added by the compiler). 'Naked' functions are seen as a more convenient alternative to functions defined in the 'global_asm!'. #[unsafe(naked)] pub unsafe extern 'sysv64' fn wrapping_add(a: u64, b: u64) -> u64 { core::arch::naked_asm!( 'add rax, rdi, rsi', 'ret' ); }
- The predicate language used in the conditional compilation attributes 'cfg' and 'cfg_attr' (which allow including or excluding parts of code based on specified conditions) has been enhanced to support boolean literals 'true' and 'false', which are defined as configurations that are always enabled or always disabled. These literals can also be used in the 'cfg!' macro and in the '[target]' tables in manifests and configurations for Cargo. The expressions cfg(true) and cfg(false) can be used instead of cfg(all()) and cfg(any()) for a clearer expression of intent.
- The Cargo package manager includes automatic garbage collection for clearing the cache in the user's home directory. Previously cached packages with downloaded dependencies were not cleared, leading to a continuous increase in disk space consumption. The enabled garbage collection mechanism will automatically delete externally loaded crate files that haven't been accessed for more than 3 months, and locally installed crate files that haven't been accessed for more than a month. Cache clearance does not trigger when using the "--offline" or "--frozen" options in crage.
- A new batch of APIs has been promoted to stable, including stabilized methods and trait implementations:
- Cell::update
- impl Default for *const T
- impl Default for *mut T
- mod ffi::c_str
- HashMap::extract_if
- HashSet::extract_if
- hint::select_unpredictable
- proc_macro::Span::line
- proc_macro::Span::column
- proc_macro::Span::start
- proc_macro::Span::end
- proc_macro::Span::file
- proc_macro::Span::local_file
- ::as_chunks
- ::as_rchunks
- ::as_chunks_unchecked
- ::as_chunks_mut
- ::as_rchunks_mut
- ::as_chunks_unchecked_mut
- The ‘const’ attribute has been applied in the functions:
- NonNull::replace
- ::replace
- std::ptr::swap_nonoverlapping
- Cell::replace
- Cell::get
- Cell::get_mut
- Cell::from_mut
- Cell::as_slice_of_cells
- The first level of support for the target platform i686-pc-windows-gnu has been removed.
Additionally, events related to Rust can be noted:
- The Munal OS project is developing an experimental operating system written in Rust and based on the unikernel concept. Munal OS does not use preemptive multitasking, memory page mapping, or virtual address space (memory layout is based on UEFI). The kernel and applications run in the same address space using a security model based on WASM sandbox isolation (includes the wasmi engine for running applications in WebAssembly bytecode).
The operating system is equipped with a graphical interface and supports keyboard and mouse management. A custom toolkit with a widget library is used for developing graphical applications. For networking, a TCP stack and network device driver are offered. Among the applications available for Munal OS are: a web browser with basic support for HTML and HTTPS, a text editor, and a terminal for executing Python code. The code is open under the MIT license.

- The release of the Asterinas 0.15.2 kernel has taken place, written in Rust and providing an ABI compatible with the Linux kernel. The kernel supports x86-64 and RISC-V architectures, implementing 206 of 368 system calls from Linux. A total of 45 developers, mainly from various Chinese universities, are involved in the kernel's development. The kernel is built using a 'framekernel' architecture, where kernel components are placed in a shared address space, and security is achieved through logical separation of secure code from potentially insecure code. All system calls, file systems, and drivers are implemented at the OS Services level and cannot include unsafe blocks. The code is distributed under the MPL 2.0 license.
- A utility named rsched has been prepared for the Linux kernel, which allows for the analysis of statistics regarding the task scheduler's performance. In practice, the utility allows for the assessment of scheduler decisions related to resource allocation for processes, as well as tracking delays arising during scheduling. The BPF subsystem is used for data collection in the kernel, while the user-space toolset is written in Rust. The utility's author is Chris Mason, the creator and chief architect of the Btrfs file system.
- Collabora has announced the development of a variant of the Coccinelle toolset for the Rust programming language. Coccinelle was originally designed for automating the search and transformation of C code in the Linux kernel. Transformations are specified in the form of rules that resemble abstracted patches, not tied to any specific position in the code.
- The GNOME developers have introduced a library for image loading called glycin, written in Rust, which provides image decoding using sandbox isolation. It supports the delivery of decoded content via gdk::Textures and metadata extraction. Wrappers are provided for using glycin in GTK4, as well as a backend for integrating glycin into the GdkPixbuf library, used in GNOME for image loading. Glycin is already utilized in the Loupe image viewer, which is offered by default in GNOME. Additionally, the backend for GdkPixbuf allows glycin to be used in GNOME Shell, thumbnail generators, and various GNOME applications, without requiring changes to these programs.
Source: opennet.ru

