I77537 StackDocsTechnology
Related
From Traditional to Digital: How Western Union Launched USDPT on SolanaAWS DevOps Agent and Security Agent Now Generally Available: Autonomous Cloud Operations Reach New MilestoneTop 5 Things You Need to Know About PhpStorm 2026.2 EAPYour Step-by-Step Guide to Unified API and AI Governance with Azure API ManagementUnlocking Maximum Power: A Complete Guide to Bosch's Performance Upgrade 2.0Austrian-Albanian Police Takedown of €50 Million Crypto Scam Ring: How They OperatedApple Releases Safari Technology Preview 237 with Major Accessibility and CSS OverhaulsKubernetes v1.36 GA: Volume Group Snapshots Explained

Rust 1.95.0 Released: New Macro, Enhanced Pattern Matching, and API Stabilizations

Last updated: 2026-05-15 18:16:45 · Technology

Overview

The Rust programming language has reached version 1.95.0, bringing a set of improvements that streamline development and expand the language's capabilities. Whether you're a seasoned Rustacean or new to the ecosystem, this release introduces features designed to make conditional compilation more intuitive, pattern matching more powerful, and code more robust. Below, we delve into the highlights of this latest stable release.

Rust 1.95.0 Released: New Macro, Enhanced Pattern Matching, and API Stabilizations
Source: blog.rust-lang.org

New cfg_select! Macro

One of the standout additions in Rust 1.95 is the cfg_select! macro, which acts as a compile-time conditional selector. It works similarly to a match statement but evaluates configuration predicates (like cfg attributes) to choose an arm. This eliminates the need for the popular cfg-if crate for many use cases, offering a built-in alternative with a slightly different syntax. The macro expands to the right-hand side of the first arm whose predicate evaluates to true.

Example Usage

The following snippet demonstrates how cfg_select! can be used to define platform-specific code:

cfg_select! {
    unix => {
        fn foo() { /* Unix-specific logic */ }
    }
    target_pointer_width = "32" => {
        fn foo() { /* Non-Unix, 32-bit logic */ }
    }
    _ => {
        fn foo() { /* Fallback implementation */ }
    }
}

let is_windows_str = cfg_select! {
    windows => "windows",
    _ => "not windows",
};

This makes it easier to write platform-agnostic code without resorting to multiple cfg attributes or external crates.

Enhanced Pattern Matching with if-let Guards

Rust 1.95 builds on the let chains stabilized in Rust 1.88 by bringing conditional pattern matching directly into match expressions. Now you can use if let guards within match arms, enabling more concise and expressive logic.

Example

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

Note that the compiler does not currently consider patterns matched in if let guards as part of exhaustiveness checking, consistent with how regular if guards are handled.

Stabilized APIs

This release stabilizes a wide range of APIs, particularly around MaybeUninit, atomic types, and collection operations. Below is a list of the newly stable items:

MaybeUninit and Cell Conversions

  • MaybeUninit<[T; N]>: From<[MaybeUninit<T>; N]>
  • MaybeUninit<[T; N]>: AsRef<[MaybeUninit<T>; N]>
  • MaybeUninit<[T; N]>: AsRef<[MaybeUninit<T>]>
  • MaybeUninit<[T; N]>: AsMut<[MaybeUninit<T>; N]>
  • MaybeUninit<[T; N]>: AsMut<[MaybeUninit<T>]>
  • [MaybeUninit<T>; N]: From<MaybeUninit<[T; N]>>
  • Cell<[T; N]>: AsRef<[Cell<T>; N]>
  • Cell<[T; N]>: AsRef<[Cell<T>]>
  • Cell<[T]>: AsRef<[Cell<T>]>

Atomic Operations

  • bool: TryFrom<{integer}>
  • AtomicPtr::update
  • AtomicPtr::try_update
  • AtomicBool::update
  • AtomicBool::try_update
  • AtomicIn::update
  • AtomicIn::try_update
  • AtomicUn::update
  • AtomicUn::try_update

Collection Methods

  • Vec::push_mut
  • Vec::insert_mut
  • VecDeque::push_front_mut
  • VecDeque::push_back_mut
  • VecDeque::insert_mut
  • LinkedList::push_front_mut
  • LinkedList::push_back_mut
  • LinkedList::insert_mut

Additional Stabilizations

  • cfg_select!
  • mod core::range
  • core::range::RangeInclusive
  • core::range::RangeInclusiveIter
  • core::hint::cold_path
  • <*const T>::as_ref_unchecked
  • <*mut T>::as_ref_unchecked
  • <*mut T>::as_mut_unchecked

How to Update

If you have a previous Rust version installed via rustup, updating to 1.95.0 is straightforward. Run the following command:

rustup update stable

If you don't have rustup yet, grab it from the official Rust website. For those eager to test future releases, you can switch to the beta or nightly channels using rustup default beta or rustup default nightly. Please report any issues you encounter on the Rust issue tracker.

Conclusion

Rust 1.95.0 continues the language's tradition of incremental yet impactful improvements. The cfg_select! macro simplifies conditional compilation, if let guards enrich pattern matching, and the newly stabilized APIs offer more flexibility in working with memory, concurrency, and collections. As always, the Rust team encourages you to experiment with these features and provide feedback for future releases.