Paul Krill
Editor at Large

Rust 1.81 stabilizes Error trait

news
Sep 9, 20243 mins

Stabilization of the Error trait in Rust core allows the usage of the trait in #![no_std] libraries. Sort algorithms also were improved in the latest Rust release.

A rusty crown sits on an anvil.
Credit: AL-art/Shutterstock

Rust 1.81 is now available, with the newest version of the memory-safe language, featuring a stabilization of the Error trait in the Rust core library.

Rust 1.81 was released September 5. Developers with a previous version of Rust installed via rustup can upgrade using the rustup update stable command. Developers can install rustup from the rust-lang.org.

With Rust 1.81, the Error trait is stabilized in core, allowing usage of the trait in #![no_std] libraries. Error is a trait representing the basic expectations for error values. The stabilization primarily enables the wider Rust ecosystem to standardize on the same Error trait, regardless of the environments targeted by the library. The no_std attribute allows developers to build Rust applications without using the Rust standard library (std).

Rust 1.81 also features new and improved sort implementations. Both the stable and the unstable sort implementations in the standard library have been updated to new algorithms that improve compilation time and runtime performance. The new sort algorithms try to detect incorrect implementations of Ord that prevent these from being able to produce a meaningfully sorted result and will panic on these cases rather than returning randomly arranged data. Users dealing with these panics should audit ordering implementations to ensure they satisfy the requirements documented in PartialOrd and Ord.

Rust 1.81 also stabilizes a new lint level, expect, which allows explicitly noting that a particular lint should occur and warning if it does not. The intended use case is temporarily silencing a lint, whether due to bugs or ongoing refactoring, while wanting to know when the lint is no longer necessary.

Also in Rust 1.81:

  • Developers will be informed directly in the compiler message if a lint level is changed for some reason.
  • APIs have been stabilized such as core::error, fs:exists, IoSlice::advance, and PanicHookInfo.
  • Usage of the wasm32-wasi target, which targets WASI 1.0, now will issue a compiler warning and request users  switch to the wasm32-wasip1 target instead.
  • Std::process::Command now correctly escapes arguments when invoking batch files on Windows in the presence of trailing whitespaces or periods.

Rust 1.81 follows Rust 1.80, released January 25, which introduced lazy types to delay initialization of data until first access.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author