Emeditor

Rust 1.95.0: Key Features and Enhancements

Published: 2026-05-03 13:54:24 | Category: Technology

Welcome to the latest stable release of Rust, version 1.95.0! This update brings powerful new tools to make your code more expressive and safer. Whether you're a seasoned Rustacean or just starting out, there's something here for you. Let's dive into the highlights, from a new compile-time configuration macro to improved pattern matching capabilities. If you haven't updated yet, simply run rustup update stable to get the latest goodness.

How do I install or update to Rust 1.95.0?

If you already have Rust installed via rustup, updating is a breeze. Open your terminal and run:

Rust 1.95.0: Key Features and Enhancements
Source: blog.rust-lang.org
rustup update stable

This command fetches the latest stable release and sets it as your default toolchain. If you don't have rustup yet, head over to the official Rust website to get it. Once installed, you can also test upcoming features by switching to the beta or nightly channels with rustup default beta or rustup default nightly. Your feedback on those channels helps shape future releases!

What is the new cfg_select! macro and how does it work?

Rust 1.95.0 introduces cfg_select!, a macro that lets you perform compile-time branching based on configuration predicates. Think of it as a match for cfg conditions. The macro expands to the right-hand side of the first arm whose predicate evaluates to true. For example:

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

This replaces the popular cfg-if crate with a built-in solution, though the syntax differs slightly. You can also use it in expressions, like cfg_select! { windows => "windows", _ => "not windows" }. It's a clean way to handle platform-specific code without relying on external libraries.

What are if-let guards in match expressions?

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

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

Here, the if let guard runs compute(x) and only enters the arm if it returns Ok(y). This keeps your code concise and avoids nested matches. Note that the compiler does not consider patterns inside if-let guards for exhaustiveness checking (similar to regular if guards), so you may still need a wildcard arm.

What are some of the newly stabilized APIs in Rust 1.95.0?

This release stabilizes a large set of APIs, particularly around MaybeUninit, Cell, and atomics. Key additions include:

  • MaybeUninit<[T; N]>: Now implements From, AsRef, and AsMut conversions between arrays and slices.
  • Cell<[T; N]>: Added AsRef implementations for arrays and slices.
  • bool: TryFrom<{integer}>: Allows safe conversion from integers to booleans.
  • Atomic operations: AtomicPtr, AtomicBool, and atomic integer types now have update and try_update methods.
  • Vec and VecDeque: New methods like push_mut, insert_mut provide in-place modification of elements.
  • Raw pointer methods: as_ref_unchecked and as_mut_unchecked for *const T and *mut T.

These additions improve ergonomics and safety when working with low-level memory and concurrency.

What is the new core::range module?

Rust 1.95.0 stabilizes the core::range module, which provides additional range types and iterators. Notably, it includes RangeInclusive and RangeInclusiveIter. These are similar to the existing inclusive range (..=) but with more explicit types for generic programming. This module helps standardize range-related utilities that were previously only available in std or external crates.

Are there any other notable additions or changes?

Yes! The core::hint::cold_path function is now stable. It marks a branch as unlikely to be taken, helping the compiler optimize code paths. Additionally, several collection types like LinkedList gained push_front_mut and similar methods for in-place mutation. These small enhancements make everyday Rust coding more convenient and performant. For the full list of changes, check out the detailed release notes.