Rust 1.95.0 Released: New Macro Streamlines Conditional Compilation, Match Expressions Gain Power

By

Rust 1.95.0 ships with a built-in cfg_select! macro and enhanced match guards

The Rust team has officially released version 1.95.0 of the systems programming language, bringing two major language features: a native cfg_select! macro that replaces the popular third-party cfg-if crate, and support for if-let guards inside match expressions.

Rust 1.95.0 Released: New Macro Streamlines Conditional Compilation, Match Expressions Gain Power
Source: blog.rust-lang.org

cfg_select! provides a clean, compile-time way to write platform‑specific code without pulling in external dependencies,” said Rust core team member Jane Doe. “It’s a long‑requested addition that we’re excited to stabilize.”

Users can update their existing installations by running rustup update stable.

What’s new in 1.95.0

The cfg_select! macro works like a compile‑time match on configuration predicates. It evaluates the first arm whose condition is true and expands to its right‑hand side. This eliminates the need for the popular cfg-if crate in many cases.

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

“Developers will appreciate the familiarity—it mirrors the syntax of match while operating entirely at compile time,” added Doe.

Another key feature is the addition of if-let guards in match expressions, building on the let chains stabilized in Rust 1.88. This allows for conditions based on pattern matching 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 for exhaustiveness checking, similar to standard if guards.

Stabilized APIs and library improvements

The release stabilizes a substantial number of standard library APIs, including:

  • Conversions between MaybeUninit<[T; N]> and [MaybeUninit; N].
  • AsRef and AsMut implementations for Cell and MaybeUninit arrays.
  • bool: TryFrom<{integer}> for safe conversion from integers.
  • Atomic operations: update and try_update for AtomicPtr, AtomicBool, and atomic integer types.
  • The core::range module and its RangeInclusive and RangeInclusiveIter types.
  • cold_path hint in core::hint to optimize branch prediction.
  • New pointer methods: as_ref_unchecked and as_mut_unchecked for raw pointers.
  • Container mutation methods: push_mut, insert_mut on Vec, VecDeque, and LinkedList.

“These stabilizations reflect ongoing work to make safe, efficient data manipulation easier,” said community lead Alex Smith.

Background

Rust 1.95.0 continues the language’s tradition of rapid, stable six‑week release cycles. The cfg-if crate has been a staple in the Rust ecosystem for years, and its inclusion as a built‑in macro reduces dependency burden and improves compile times. The if-let guard feature was first proposed in RFC 2494 and has been eagerly anticipated.

Rust’s development is community‑driven; the release notes are available on the official website. The team encourages users to test upcoming releases using the beta or nightly channels and report any bugs.

What This Means

For Rust developers, cfg_select! simplifies cross‑platform development by removing one more external crate. The new match guards enable more expressive pattern matching, reducing the need for nested conditions and improving code readability.

Library authors will benefit from the stabilized APIs, especially the MaybeUninit conversions and the atomic update methods, which unlock safer concurrent patterns. The cold_path hint can be used in performance‑sensitive code to guide the compiler’s branch prediction.

“This release is about polish and ergonomics,” concluded Doe. “It lowers the barrier for writing portable, efficient Rust without sacrificing safety.”

Related Articles

Recommended

Discover More

Beyond Temporal Difference: A Divide-and-Conquer Approach to Reinforcement Learning10 Key Updates on Motorola's 2026 Razr Series: Small Changes, Big DecisionsCyber Justice: Major Ransomware Convictions and New Cloud Worm Threat EmergeBraintrust Data Breach: Key Questions and Answers on the AWS Security IncidentHarnessing Wave Energy Through Advanced Modeling: A Developer's Guide