Announcing Rust 1.98.0
The Rust team has unveiled Rust 1.98.0, a programming language designed to help developers create dependable and high-performance software. For those already using Rust via rustup, upgrading to 1.98.0 is simple. Those without Rust can obtain it from the official site and review the 1.98.0 release notes. Those interested in contributing to future releases may prefer the beta (rustup default beta) or nightly (rustup default nightly) channels. Users are encouraged to report any issues encountered.
A noteworthy addition to Rust 1.98.0 is the introduction of algebraic methods for the floating-point types f32 and f64. These methods enable optimizations on addition, subtraction, multiplication, division, and remainder operations by leveraging the algebraic properties of real numbers, despite the inherent limitations of floating-point representations.
Although the specific optimizations are not defined, they could mirror those achieved through -ffast-math in other languages. For instance, floating-point addition is not associative, so an expression like a + b + c + d must be evaluated in the left-associative order (such as ((a + b) + c) + d). However, utilizing algebraic_add, the compiler can reorder the operations (e.g., (a + b) + (c + d)) to compute partial sums concurrently. These methods, while non-deterministic, do not lead to undefined behavior.
Additionally, all primitive integer types now feature a format_into method, which accepts a mutable reference to a NumBuffer Self. This buffer is sized to accommodate the decimal representation of any value of that type. The method returns a formatted &str with a lifetime tied to the buffer, bypassing the dynamic dispatch associated with buffered write! formatting.
Consequently, format_into can potentially enhance performance. The itoa-benchmark repository indicates that format_into performs comparably to itoa, suggesting it could serve as a viable replacement for similar dependencies.
In Rust 1.96.0, a bug in the compiler resulted in undefined behavior when moving a Box that had been dropped. ManuallyDrop exacerbated this issue, propagating the undefined behavior to scenarios where moving ManuallyDrop Box _ where the box had been dropped would also be considered undefined behavior. This release rectifies the issue, ensuring that such code no longer constitutes undefined behavior.
The ManuallyDrop documentation has been updated, providing a stable guarantee that this code will remain safe in the future. For further details, consult the ManuallyDrop documentation and RFC 3336.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.