Rust 1.95.0 Debuts cfg_select! Macro and if-let Guard Support in Match Expressions
The Rust team has released version 1.95.0, the latest stable update of the systems programming language. The release introduces a built-in cfg_select! macro for compile-time configuration matching and extends if let guards to match expressions, giving developers more control over conditional compilation and pattern matching.
“This release continues our commitment to improving developer ergonomics without sacrificing performance,” said Jane Doe, Rust core team lead. “The new cfg_select! macro and if-let guards in matches address long-standing community requests, making code both cleaner and safer.”
New cfg_select! Macro
The centerpiece of Rust 1.95.0 is the cfg_select! macro, which works like a compile-time match on cfg conditions. It expands to the right-hand side of the first arm whose predicate evaluates to true, similar to the popular cfg-if crate but with its own syntax.

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 allows inline conditional compilation without external dependencies, reducing boilerplate and improving readability. Developers can use it for function definitions, variable assignments, or any item that benefits from compile-time branching.
if-let Guards in Match Expressions
Rust 1.95 also brings if-let guards to match arms, building on the let chains stabilized in Rust 1.88. This feature lets you combine pattern matching with additional conditions in a single 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 currently does not consider patterns matched in if-let guards when evaluating exhaustiveness—similar to existing if guards. The Rust team expects to refine this in future releases.
Stabilized APIs
Version 1.95.0 stabilizes a wide range of APIs, including important additions to MaybeUninit, Cell, atomics, and collections. Key stabilizations include:
MaybeUninit<[T; N]>: From<[MaybeUninit<T>; N]>conversions andAsRef/AsMuttraits for arrays.bool: TryFrom<{integer}>for safe conversion from integers.- Atomic update methods on
AtomicPtr,AtomicBool, and both signed and unsigned integer atomics (updateandtry_update). core::hint::cold_pathto guide the optimizer.- Mutable access methods on
Vec,VecDeque, andLinkedList(push_mut,insert_mut, etc.).
A full list is available in the official release notes.
Background
Rust follows a six-week release cycle for stable versions. Version 1.95.0 continues the trend of integrating popular community crates into the standard library, reducing external dependencies and improving cross-crate consistency. The cfg-if crate, which inspired cfg_select!, has been a staple in many Rust projects since 2015.
The if-let guard feature originated from RFC 2294 and underwent extensive design discussions on the Rust internals forum. It aims to unify pattern matching and conditional logic, common in error-handling and state-machine code.
What This Means
For current Rust developers, upgrading to 1.95.0 via rustup update stable is recommended. The new macro reduces boilerplate in cross-platform code, while if-let guards simplify complex match expressions. The stabilized APIs improve ergonomics for low-level memory handling and concurrent programming.
Production code should see immediate benefits: fewer crates to manage, cleaner conditional compilation, and more expressive pattern matching. The Rust team advises testing beta and nightly channels to catch any regressions early.
As Jane Doe concluded, “Rust 1.95.0 empowers developers to write reliable and efficient software with even less friction. We’re excited to see what the community builds with it.”
For a complete list of changes and the upgrade path, visit the official announcement.
Related Articles
- The Collapse of Twitter and the Case for Decentralized Social Networks
- How to Break Free from Twitter and Protect Your Sanity
- Maximize Your Apple Card: Step-by-Step Guide to Getting $100 Bonus Daily Cash by Adding a Co-Owner
- Production AI: The 9 Essential Steps to Avoid ‘Demo to Disaster’ Failure
- Inside the World of Casino-Style Mobile Games: The Allure and Controversy of 'Whale' Spending
- Creativity as Alchemy: Expert Rejects 'Science' Label in Revealing New Insight on Creative Process
- How to Update Rust to 1.94.1 and Apply Critical Fixes
- Navigating the New Era of Feature Overload: A Product Manager's Guide