Xshell Pro
📖 Tutorial

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

Last updated: 2026-05-10 04:03:28 Intermediate
Complete guide
Follow along with this comprehensive guide

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:

  • MaybeUninit conversions: MaybeUninit<[T; N]> now implements From<[MaybeUninit<T>; N]> and AsRef/AsMut for slices and arrays.
  • Atomic pointer updates: AtomicPtr::update and try_update along with similar methods for AtomicBool and integer types.
  • Unsafe pointer dereferences: <*const T>::as_ref_unchecked and <*mut T>::as_mut_unchecked.
  • Collection methods: Vec::push_mut, VecDeque::push_front_mut, LinkedList::push_front_mut, and insert_mut variants.
  • New module: core::range with RangeInclusive and its iterator.
  • Optimization hint: core::hint::cold_path to mark unlikely code paths.
  • Conversion: bool: TryFrom<{integer}> for fallible conversion from integers.

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.