Rust 1.94.0 Released: Enhanced Iteration, Configuration, and TOML Support

From Wwwspill, the free encyclopedia of technology

Table of Contents

Updating to Rust 1.94.0

The Rust team has officially released version 1.94.0, continuing the language's commitment to reliability and performance. This release introduces several improvements to the standard library and build tools, making everyday coding more efficient. If you already have Rust installed via rustup, updating is straightforward:

rust released enhanced
Image via Flickr
$ rustup update stable

If you're new to Rust, you can download rustup from the official installer page. For those eager to experiment with upcoming features, you can switch to the beta or nightly channels using rustup default beta or rustup default nightly. Please report any bugs you encounter to help shape future releases.

Array Windows for Constant-Size Slices

Slice iteration gets a powerful new method in Rust 1.94.0: array_windows. While the existing windows method yields dynamically sized slices (&[T]), array_windows returns fixed-size arrays (&[T; N]) when the window length is known at compile time. This eliminates the need for manual indexing and runtime bounds checking, often allowing the compiler to infer the window size from usage.

Consider a classic Advent of Code 2016 puzzle: detecting ABBA patterns (e.g., xyyx or abba). With array_windows, the implementation is concise and type-safe:

fn has_abba(s: &str) -> bool {
    s.as_bytes()
        .array_windows()
        .any(|[a1, b1, b2, a2]| (a1 != b1) && (a1 == a2) && (b1 == b2))
}

Here, the closure's destructuring pattern tells Rust to use windows of 4 elements. The previous approach with .windows(4) would yield slices, requiring manual indexing and relying on the optimizer to remove bounds checks. array_windows provides both safety and performance out of the box.

Cargo Config Inclusion for Better Organization

Cargo’s configuration system now supports an include key in .cargo/config.toml. This feature helps you split configuration files, share common settings across projects, and manage environment-specific overrides. The included files can be marked as optional, making them ideal for optional developer tooling or local preferences.

rust released enhanced
Image via Flickr

Here’s how you can use the include key:

# Simple list of paths
include = [
    "frodo.toml",
    "samwise.toml",
]

# Inline tables for optional includes
include = [
    { path = "required.toml" },
    { path = "optional.toml", optional = true },
]

For full details, refer to the official include documentation.

TOML 1.1 Support in Cargo

Cargo now parses manifests and configuration files using TOML v1.1. This update brings several quality-of-life improvements to how you write Cargo.toml and other TOML files. Key changes include:

  • Inline tables can now span multiple lines and include trailing commas.
  • New escape sequences: \xHH (hexadecimal byte) and \e (escape character).
  • Optional seconds in times: if omitted, seconds default to 00.

For example, a dependency like this:

serde = { version = "1.0", features = ["derive"] }

can now be formatted more readably:

serde = {
    version = "1.0",
    features = ["derive"],
}

Note that using TOML 1.1 features in your Cargo.toml will raise your minimum supported Rust version (MSRV) to Rust 1.94.0 or later. For a complete list of changes, see the TOML v1.1 release notes.

Rust 1.94.0 also includes numerous other improvements and bug fixes. Check the full release notes for the complete list.