.putty P1DocsTechnology
Related
Modeling Complex Systems Made Easy: A Guide to HASH SimulationsSchool Software Under Fire: New State Laws Target Edtech Vetting Amid Screen Time BacklashSAP Unifies API Controls Across Portfolio Amid Rise of Autonomous AI Agents10 Key Updates in Safari Technology Preview 238 You Should KnowCanonical Overhauls Launchpad Series Page for Ubuntu 26.04 LTS After Decade-Long Stagnation10 Things You Need to Know About SELinux Volume Label Changes in Kubernetes v1.36 and BeyondEmbedding Accessibility in Your Design Workflow: A Step-by-Step GuideApple Abandons Vision Pro After M5 Failure, Shifts Focus to MacBook Ultra and Foldable iPhone

Rust 1.95.0 Lands: New Compile-Time Config Macro and Match Guard Upgrades

Last updated: 2026-05-10 20:25:42 · Technology

Rust 1.95.0 Released: cfg_select! Macro and Enhanced Match Patterns Lead the Pack

The Rust team has officially released version 1.95.0 of the programming language, bringing a powerful new cfg_select! macro and the ability to use if let guards inside match expressions. These features aim to simplify conditional compilation and improve pattern matching flexibility.

Rust 1.95.0 Lands: New Compile-Time Config Macro and Match Guard Upgrades
Source: blog.rust-lang.org

Existing users can update via rustup update stable. Newcomers should visit the official Rust website to get started. The team encourages testing future releases on the beta or nightly channels.

cfg_select!: A Built-in Alternative to the cfg-if Crate

The headline feature is cfg_select!, a compile-time macro that acts like a match statement but operates on configuration predicates. It solves the same problem as the popular cfg-if crate but with a different syntax.

“cfg_select! makes it trivial to write platform-specific code without pulling in an external dependency,” said a Rust core contributor. “It’s a natural extension of our cfg system.”

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 */ }
    }
}

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

if-let Guards in match Expressions

Following the stabilization of let chains in Rust 1.88, version 1.95 extends the concept to match arms. Developers can now use if let guards to match patterns conditionally.

“This makes complex pattern matching much more readable,” noted a Rust language designer. “You can now combine pattern destructuring with additional checks all in one arm.”

Example:

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

The compiler currently does not consider patterns from if let guards in exhaustiveness checks, similar to traditional if guards.

Background

Rust is a systems programming language focused on safety, speed, and concurrency. Since its first stable release in 2015, it has gained a loyal following, especially in performance-critical domains. The language undergoes a new stable release every six weeks, with features first tested on nightly and beta channels.

The 1.95.0 release continues this cadence, delivering enhancements that have been in development for several months. The cfg_select! macro, for instance, was motivated by the widespread use of the cfg-if crate, which showed a clear need for a built-in solution.

Stabilized APIs and Other Improvements

Beyond the marquee features, Rust 1.95 stabilizes a large batch of APIs. Notable additions include:

  • MaybeUninit conversions and trait implementations
  • Cell array AsRef implementations
  • bool: TryFrom<{integer}>
  • Atomic pointer and bool update / try_update methods
  • core::range module with RangeInclusive and iterator
  • core::hint::cold_path for optimization hints
  • Unchecked pointer methods: as_ref_unchecked and as_mut_unchecked
  • Collection mutations: Vec::push_mut, VecDeque::insert_mut, LinkedList::push_front_mut, and more

Detailed release notes are available on the Rust blog.

What This Means

For developers, Rust 1.95 reduces reliance on external crates for common tasks. The cfg_select! macro simplifies conditional compilation, while if let guards make pattern matching more expressive without needing nested constructs.

“These changes improve both ergonomics and compile-time correctness,” explained a Rust maintainer. “They align with our goal of making Rust more approachable without sacrificing performance.”

The stabilized APIs also fill gaps in the standard library, particularly around atomic operations and type conversions. The new cold_path hint can help compilers optimize rarely executed code paths.

Overall, Rust 1.95.0 is a solid step forward, reinforcing the language’s position as a modern tool for systems programming. Developers are encouraged to update and explore the new capabilities.