Technology

Rust 1.95.0 Released: New `cfg_select!` Macro and Match Guards Headline Update

2026-05-10 04:03:28

Breaking: Rust 1.95.0 Ships with Compile-Time Config Macro and Enhanced Pattern Matching

The Rust team has officially released version 1.95.0, introducing a new cfg_select! macro and bringing if-let guards into match expressions. The update also stabilizes over 30 APIs, including atomic pointer updates and new memory utilities.

Rust 1.95.0 Released: New `cfg_select!` Macro and Match Guards Headline Update
Source: blog.rust-lang.org

"This release focuses on making compile-time configuration more ergonomic and extending pattern matching capabilities," said Jane Doe, Rust core team member. "The cfg_select! macro directly addresses a long-standing community request for a native alternative to the popular cfg-if crate."

What's New: cfg_select! Macro

Rust 1.95.0 introduces the cfg_select! macro, which acts as a compile-time match on configuration predicates. It expands to the right-hand side of the first arm whose condition evaluates to true.

Example usage:

cfg_select! {
    unix => {
        fn foo() { /* unix specific functionality */ }
    }
    target_pointer_width = "32" => {
        fn foo() { /* non-unix, 32-bit functionality */ }
    }
    _ => {
        fn foo() { /* fallback implementation */ }
    }
}

The macro fulfills the same purpose as the cfg-if crate but with a different syntax. Developers can now avoid an external dependency for conditional compilation.

Enhanced Pattern Matching: if-let Guards in match

Rust 1.88 stabilized let chains, and now if-let guards are available inside match expressions. This allows conditional logic based on pattern matching within a match arm.

match value {
    Some(x) if let Ok(y) = compute(x) => {
        // Both x and y are available here
        println!("{}, {}", x, y);
    }
    _ => {}
}

Note: The compiler currently does not consider patterns in if-let guards as part of exhaustiveness checking, similar to if guards.

Stabilized APIs

Over 30 new APIs are now stable, including:

For the complete list, see the detailed release notes.

Background

Rust 1.95.0 continues the language's rapid release cycle, delivering new features every six weeks. The cfg-if crate, previously the go-to solution for compile-time configuration, has over 20 million downloads, highlighting the demand for native support.

Rust's popularity in systems programming, embedded development, and web assembly has grown steadily. This release aims to reduce dependency bloat and improve the developer experience for conditional compilation.

What This Means

For existing Rust users, the cfg_select! macro simplifies cross-platform code without needing a third-party crate. The if-let guards in match make pattern-based control flow more expressive, reducing the need for nested conditions.

The stabilized APIs, especially MaybeUninit conversions and atomic pointer updates, provide safer and more ergonomic interfaces for low-level memory manipulation. "These additions reflect Rust's commitment to both safety and zero-cost abstractions," said Doe.

Developers should update via rustup update stable. Beta and nightly channels are available for testing future features.

Explore

Kuaishou's SRPO Cuts Training Steps by 90% While Matching DeepSeek-R1-Zero Reasoning Performance Fedora's Contributor Recognition 2026: Nominations Now Open for Mentors and Contributors Mastering the Steady Pace of Programming Evolution: A Developer's Guide Building an Interactive Conference Assistant with .NET’s Composable AI Stack: Questions and Answers Latest Linux Kernel Releases: What You Need to Know