.mobaxterm19436666DocsTechnology
Related
Stop Overlooking Experience: A Step-by-Step Guide to Hiring Older Workers for a Competitive EdgeAI Coding Agents Force Rethink of Test-Driven Development: 'Harness' Design Emerges as Critical SkillHow to Explore the Pentagon's New UAP Document RepositoryOrion for Linux Beta 0.3 Brings Integrated Content Blocker and Download ManagerApple Rolls Out Safari Technology Preview 242 with Major CSS and Accessibility UpgradesRebuilding GitHub Enterprise Server Search for High Availability: Key Questions Answered10 Key Updates on Motorola's 2026 Razr Series: Small Changes, Big DecisionsHow to Prevent Signal Message Recovery from iPhone Notification Data

Rust 1.95.0 Arrives: New Macro, Enhanced Pattern Matching, and More

Last updated: 2026-05-02 12:34:12 · Technology

Introduction

The Rust team has unveiled version 1.95.0 of the language, continuing its mission to empower developers to build reliable and efficient software. This release introduces two major features: a compile-time conditional macro and improved pattern matching in match expressions, along with a host of stabilized APIs that expand the standard library's capabilities.

Rust 1.95.0 Arrives: New Macro, Enhanced Pattern Matching, and More
Source: blog.rust-lang.org

If you already have Rust installed via rustup, updating is straightforward:

$ rustup update stable

For those new to Rust, visit the official website to get rustup. Detailed release notes for 1.95.0 are available online. Community members are encouraged to test upcoming releases by switching to the beta or nightly channels (rustup default beta or rustup default nightly) and reporting any bugs encountered.

New Compile-Time Conditional: cfg_select!

Rust 1.95.0 introduces the cfg_select! macro, which provides a clean, compile-time alternative to the popular cfg-if crate. This macro works like a match on configuration predicates, expanding to the right-hand side of the first arm whose condition evaluates to true. The syntax differs from cfg-if but remains intuitive:

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

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

This macro is particularly useful for writing platform-specific code without relying on external crates, reducing dependencies and streamlining conditional compilation.

Enhanced Pattern Matching: if let Guards in match

Following the stabilization of let chains in Rust 1.88, version 1.95.0 extends conditional pattern matching into match expressions with if let guards. This allows you to combine pattern matching with an additional if let condition directly inside a match arm:

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

Note that the compiler does not currently consider patterns in if let guards when evaluating exhaustiveness—similar to how ordinary if guards are treated. This feature adds flexibility to complex matching scenarios without breaking existing checks.

Stabilized APIs in Rust 1.95.0

This release stabilizes a broad set of APIs, many of which improve ergonomics for working with MaybeUninit, atomics, collections, and raw pointers. Below is the complete list of additions:

MaybeUninit and Array 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 and AsRef Improvements

  • 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

Additional Stabilizations

  • cfg_select! (macro)
  • 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
  • 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

Conclusion

Rust 1.95.0 continues the language's tradition of incremental, practical improvements. The cfg_select! macro simplifies compile-time conditionals, while if let guards expand pattern matching capabilities. The stabilized APIs bring more ergonomic implementations for memory initialization, atomic operations, and collection manipulation. As always, the Rust community encourages testing and feedback to help shape future releases.