paul_krill
Editor at Large

Rust stabilizes inline const expressions

news
Jun 14, 20242 mins
Programming LanguagesRustSoftware Development

Associated item bounds syntax also is stabilized in the Rust 1.79 release.

The Rust Team has released Rust 1.79, an update to the memory safe programming language that stabilizes both inline const expressions and the associated item bounds syntax.

Unveiled June 13, Rust 1.79 can be installed by running rustup update stable.

With Rust 1.79, const { … } blocks now are stable in the expression position, thus permitting explicitly entering a const context without needing extra declarations. Unlike const items, inline consts can make use of in-scope generics and have their type inferred rather than explicitly written, making them particularly useful for inline code snippets. This improvement makes code more succinct and easier to read, the Rust Team said.

Rust 1.79 also stabilizes the associated item bounds syntax, allowing for bounds to be put in associated type position within other bounds. This avoids a need to provide an extra, explicit generic type to constrain the associated type. The feature allows specifying bounds in a few places that previously were not possible or imposed unnecessary constraints on usage.

In another highlight of the Rust 1.79 release, the standard library distributed by the Rust project now is compiled with -Cforce-frame-pointers=yes, thus enabling downstream users to more easily profile their programs. Also in Rust 1.79, temporaries that are immediately referenced in construction now are automatically lifetime extended in match and if constructs. This offers the same behavior as lifetime extension for block constructs.

Rust 1.79 follows the May release of Rust 1.78, which emphasized diagnostic computes for compiler messages. Billed as fast and memory-efficient, Rust recently placed 10th in the June 2024 edition of the Pypl Popularity of Programming Language index.