The release of the Rust programming language 1.94 has been published. Initially developed by Mozilla, it is now maintained by the independent non-profit organization Rust Foundation. The language focuses on safe memory handling and provides tools for achieving high task execution parallelism, all while avoiding the use of garbage collectors and runtime (runtime is limited to basic initialization and support for the standard library).
Memory handling methods in Rust aim to eliminate 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, etc. To facilitate library distribution, ensure compilation, and manage project dependencies, the package manager Cargo is being developed. A repository, crates.io, is supported for hosting libraries.
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 slice type has been enhanced with the array_windows method, which creates an iterator for traversing slices in 'windows' of fixed size, shifting one element at a time. Unlike the previously available windows method, the array_windows method operates with a constant window size and returns a reference to a fixed-size array (&[T; N]) on each iteration instead of a slice of undefined size (&[T]). Since the array size is known to the compiler from the start, boundary checks can be skipped at each stage of iteration for performance improvement. let slice = [0, 1, 2, 3]; let mut iter = slice.array_windows(); assert_eq!(iter.next().unwrap(), &[0, 1]); assert_eq!(iter.next().unwrap(), &[1, 2]); assert_eq!(iter.next().unwrap(), &[2, 3]); assert!(iter.next().is_none());
- The Cargo package manager configuration files (.cargo/config.toml) have implemented the 'include' directive, allowing the content of other files to be included inline. include = [ "frodo.toml", "samwise.toml", ] include = [ { path = "required.toml" }, { path = "optional.toml", optional = true }, ]
- Manifest files and configuration files have added support for the new version of the TOML markup language 1.1, which introduces support for multi-line inline tables, escape sequences '\xHH' for inserting the hexadecimal representation of bytes, and '\e' for replacing '\u001B'. It also allows a trailing comma after the last element and skipping the specification of seconds in time values. serde = { version = "1.0", features = ["derive"] } can now be replaced with serde = { version = "1.0", features = ["derive"], }
- A new batch of APIs has been promoted to stable, including stabilized methods and trait implementations:
- ::array_windows
- ::element_offset
- LazyCell::get
- LazyCell::get_mut
- LazyCell::force_mut
- LazyLock::get
- LazyLock::get_mut
- LazyLock::force_mut
- impl TryFrom for usize
- std::iter::Peekable::next_if_map
- std::iter::Peekable::next_if_map_mut
- Built-in functions for x86 instructions avx512fp16
- Built-in functions for AArch64 instructions NEON fp16
- f32::consts::EULER_GAMMA
- f64::consts::EULER_GAMMA
- f32::consts::GOLDEN_RATIO
- f64::consts::GOLDEN_RATIO
- The ‘const’ attribute has been applied in the functions:
- f32::mul_add
- f64::mul_add
- The riscv64im-unknown-none-elf platform has been upgraded to the third support level. The third level includes basic support, but without automated testing, publication of official builds, or verification of code building capabilities.
Additionally, recent announced projects and events related to Rust can be noted:
- Ayrton Muñoz, who previously implemented support for the Sony PlayStation 1 platform in the Rust compiler and worked on porting FreeBSD to computers with Apple Silicon chips, has enabled FreeBSD to create kernel components and device drivers in Rust. A set of Kernel Programming Interface (KPI) bindings has been proposed for testing, allowing the use of Rust code in the FreeBSD kernel, along with sound driver virtio (virtio_snd) created using these bindings, a HID driver DockChannel for the keyboard in the M2 MacBook, and several low-level drivers for Mac subsystems on Apple Silicon chips.
It is noted that work on Rust bindings has been ongoing since late 2024. Currently, only part of the C-KPI has been implemented in the bindings, and they are positioned as unstable, but over time, they plan to increase stability to match the interface for the C language. The proposed example driver, virtio_snd, is suitable for playing music in QEMU. It is expected that by 2026, the Rust bindings will be sufficiently stabilized for interested developers to start using them for coding.
- Benny Siegert, involved in the development of NetBSD, has attempted to justify the reasons why support for the Rust language will not appear in the NetBSD kernel: NetBSD supports architectures for which Rust is unavailable; maintaining the existing Rust tooling in pkgsrc requires significant effort and is supported by only a few developers; Rust support in the kernel necessitates the inclusion of the Rust compiler in the base system; when bootstrapping Rust in NetBSD, a previous version of the binary package is used, which is unacceptable for self-contained distributions that are distributed in source code; the Rust release cycles are incompatible with NetBSD's development cycle and support for past branches (for instance, the NetBSD 9 branch released in 2020 is still supported, and under these conditions, a six-year-old Rust compiler would need to be supplied and maintained).
- The release of the embedded database management system Turso 0.5 has been published, written in Rust and compatible with SQLite at the SQL dialect level, database file formats, and C API. Among the advanced features is the CDC (Change Data Capture) mechanism for real-time tracking of database changes, the use of io_uring for asynchronous I/O in Linux, support for vector search, the presence of the ALTER expression for modifying the database schema, the ability to encrypt data in the database, incremental computation mode, and the "BEGIN CONCURRENT" construct.
- A project for enabling the use of the Rust standard library in programs running on the GPU.
- Emuko is a RISC-V emulator written in Rust, capable of booting Linux, supporting JIT compilation, and able to save and restore state snapshots.
- RustConn (flatpak) is a graphical interface for managing external network connections to other hosts, supporting SSH, RDP, VNC, SPICE, Telnet, Serial, Kubernetes, Zero Trust, and SFTP. The code is written in Rust using GTK4 and Wayland.
- A new branch of the project zlib-rs 0.6 has been introduced, marked as the first stable version, fully compatible with the zlib C API, suitable for seamless replacement of zlib. The project aims to create a secure alternative to the data compression library zlib. Development is being conducted with attention to the zlib-ng project, which develops a high-performance variant of zlib.
- The vcad project has been introduced, developing a parametric computer-aided design (CAD) system written in Rust and integrable with AI agents via the MCP protocol. It supports 3D modeling, simulation, working with 2D sketches, component assembly, import in STEP format, and export in STL/GLB/STEP/DXF formats.
- A speech recognition system has been released, written in Rust and using the AI model Mistral Voxtral Mini 4B Realtime and the Burn machine learning framework. The project focuses on real-time speech recognition for generating transcripts during live streaming.
- The c2rust 0.22 toolkit has been released, designed for translating C code (C99) into an unsafe representation in Rust, closely resembling the original C code structure. The resulting working framework can subsequently be used for gradually translating to idiomatic Rust and eliminating unsafe blocks.
Source: opennet.ru
