Www.itsportsbetDocsTechnology
Related
Snag Big Savings on Switch 2 Games: Splatoon Raiders and Yoshi Preorders DiscountedKubernetes v1.36 Beta: In-Place Vertical Scaling for Pod-Level ResourcesA Developer’s Guide to Installing the iOS 26.5 and iPadOS 26.5 Release Candidate10 Key Updates on Motorola's 2026 Razr Series: Small Changes, Big DecisionsApple’s Swift 6.3 Goes Live: New @c Attribute, Android SDK, and Cross-Platform Tooling Revolutionize DevelopmentNuro Granted California Permit for Driverless Lucid Gravity Robotaxi Tests Ahead of Uber Fleet RolloutSimulate Complex Systems with HASH: A Step-by-Step GuidereMarkable Launches Paper Pure: $399 E Ink Tablet Set to Replace reMarkable 2

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

Last updated: 2026-05-08 19:43:22 · Technology

The Rust team is pleased to announce the release of Rust 1.95.0, the latest stable version of the language that empowers developers to build reliable and efficient software. This release introduces a new compile-time selection macro, extends pattern matching capabilities in match expressions, and stabilizes a significant number of APIs. If you already have Rust installed via rustup, you can update with:

rustup update stable

For those new to Rust, get rustup from the official website. The full release notes are available here. If you'd like to test upcoming features, switch to the beta or nightly channels (rustup default beta or rustup default nightly) and report any bugs you encounter.

New cfg_select! Macro

Rust 1.95.0 introduces the cfg_select! macro, which acts as a compile-time conditional selection tool. It resembles the popular cfg-if crate but with its own syntax. The macro evaluates configuration predicates sequentially and expands to the right-hand side of the first arm that evaluates to true. Here is an example of its usage with functions:

Rust 1.95.0: New Macro, Enhanced Pattern Matching, and More
Source: blog.rust-lang.org
cfg_select! {
    unix => {
        fn foo() { /* unix specific functionality */ }
    }
    target_pointer_width = "32" => {
        fn foo() { /* non-unix, 32-bit functionality */ }
    }
    _ => {
        fn foo() { /* fallback implementation */ }
    }
}

You can also use it inline, as in this string assignment:

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

This macro simplifies conditional compilation by eliminating the need for external crates or repetitive cfg! checks, making code more concise and readable.

Enhanced Pattern Matching with if-let Guards

Building on the let chains stabilized in Rust 1.88, version 1.95.0 brings if let guards into match expressions. This allows you to add pattern-matching conditions directly in match arms. For example:

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 matched in if let guards as part of exhaustiveness checks—similar to regular if guards. This feature enhances expressiveness by allowing complex conditional destructuring without nesting additional match or if let statements.

Stabilized APIs

Rust 1.95.0 stabilizes a wide range of APIs, many of which improve ergonomics for MaybeUninit, Cell, atomics, pointers, and collections. Here are the highlights:

Conversions and References for MaybeUninit

  • 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]>>

Reference Implementations for Cell

  • Cell<[T; N]>: AsRef<[Cell<T>; N]>
  • Cell<[T; N]>: AsRef<[Cell<T>]>
  • Cell<[T]>: AsRef<[Cell<T>]>

Type Conversions and Atomic Operations

  • bool: TryFrom<{integer}> — Convert integer types to bool with error handling.
  • Atomic pointer and boolean update methods: AtomicPtr::update, AtomicPtr::try_update, AtomicBool::update, AtomicBool::try_update.
  • Atomic integer updates: AtomicIn::update, AtomicIn::try_update, AtomicUn::update, AtomicUn::try_update (where In and Un represent signed and unsigned integer types).

Core and Collections

  • cfg_select! macro (now stabilized).
  • New module core::range with types RangeInclusive and RangeInclusiveIter.
  • New hint function core::hint::cold_path to guide the optimizer.
  • Pointer methods: <*const T>::as_ref_unchecked, <*mut T>::as_ref_unchecked, <*mut T>::as_mut_unchecked.
  • Collection mutations: Vec::push_mut, Vec::insert_mut, VecDeque::push_front_mut, VecDeque::push_back_mut, VecDeque::insert_mut, LinkedList::push_front_mut.

These additions improve safety, ergonomics, and performance for low-level and high-level Rust code alike.

Conclusion

Rust 1.95.0 continues the language's tradition of incremental improvement. With the cfg_select! macro, if-let guards in match arms, and a robust set of stabilized APIs, developers gain powerful tools for writing clean, efficient, and context-aware code. Update your toolchain today and explore the new possibilities.