Rust 1.95.0 Lands: New `cfg_select!` Macro and Match Guards Boost Compile-Time Flexibility
Rust 1.95.0 Released: Streamlined Conditional Compilation and Enhanced Pattern Matching Take Center Stage
The Rust team has officially released version 1.95.0, bringing two long-anticipated features to stable: the cfg_select! macro and if-let guards in match expressions. The update is available immediately via rustup update stable.

“This release empowers developers with more ergonomic compile-time conditionals and richer pattern matching,” said a Rust Core Team representative. “It’s another step toward making Rust safer and more expressive without sacrificing performance.”
cfg_select! Macro: A First-Class Compile-Time Switch
Rust 1.95.0 introduces the cfg_select! macro, which acts as a compile-time match on configuration predicates. It fulfills the same role as the popular cfg-if crate but with a distinct syntax.
“The macro expands to the right-hand side of the first arm whose configuration predicate evaluates to true,” the team explained. This eliminates the need for nested cfg! attributes in many cases.
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 */ }
}
}
For simple value selection:
let is_windows_str = cfg_select! {
windows => "windows",
_ => "not windows",
};
If-Let Guards in Match: Unlocking Nested Pattern Logic
Building on the let chains stabilized in Rust 1.88, version 1.95.0 extends that power to match arms. Developers can now use if let guards to conditionally match based on further pattern matching.
“Both the outer pattern variable and the inner guard variable are available inside the arm,” noted the Rust team. Example:
match value {
Some(x) if let Ok(y) = compute(x) => {
println!("{}, {}", x, y);
}
_ => {}
}
Note: The compiler currently does not consider patterns in if let guards as part of exhaustiveness evaluation — similar to regular if guards.
Stabilized APIs: Safer Uninitialized Memory and Atomic Operations
The release also stabilizes over two dozen APIs, focusing on MaybeUninit, Cell, Atomic*, and collection mutability improvements.
Key Stabilizations
- MaybeUninit<[T; N]>: New
From,AsRef, andAsMutimplementations for easier conversion between array types. - AtomicPtr, AtomicBool, AtomicIn, AtomicUn:
updateandtry_updatemethods for atomic read-modify-write patterns without locks. bool: TryFrom<{integer}>: Safe fallible conversion from any integer to bool.- Raw pointer methods:
as_ref_uncheckedandas_mut_uncheckedfor unchecked references from raw pointers. - Collection push/insert mut:
Vec::push_mut,Vec::insert_mut, and similar forVecDequeandLinkedList. - New modules:
core::rangewithRangeInclusiveand its iterator, pluscore::hint::cold_pathfor marking unlikely branches.
The full list of stabilized APIs is available in the official release notes.
Background: Rust’s Rapid Release Cycle
Rust follows a predictable six-week release cadence. Version 1.95.0 continues this tradition, building on the let chains feature from 1.88 and responding to community demand for a built-in cfg! matching macro.
The cfg-if crate, which cfg_select! now standardizes, has been a staple in the ecosystem for handling conditional compilation in a readable way. Its inclusion as a language macro reduces external dependencies and improves compiler integration.
What This Means for Rust Developers
“With cfg_select!, platform-specific code becomes more readable and less error-prone,” said one Rust community reviewer. “It’s a natural replacement for chains of cfg! attributes.”
The if-let guard feature lets developers write concise match arms that would previously require nested matches or separate functions. This is particularly valuable in parsers, network protocol handlers, and any code with layered validation.
Stabilized APIs like Atomic*::update provide safer atomic operations without manual loops, while MaybeUninit improvements simplify low-level memory management. Performance-sensitive projects, such as game engines and embedded systems, will benefit directly.
“Upgrade today via rustup update stable,” the team urged. They also encourage testing future releases on beta and nightly channels to catch regressions early.
For complete details, see the official announcement.
Related Articles
- Porsche's Strategic Shift: Q&A on Subsidiary Closures and Core Business Focus
- The Paradox of Brain Shrinkage: Are Humans Really Getting Smarter?
- Windows 11 KB5083631 Optional Update: 34 Enhancements Including Xbox Mode and Batch File Security Boost
- Top 7 Game-Changing Features in Android 17’s New Intelligence System
- Nintendo Switch 2 Preorder Deals: Save Big on Splatoon Raiders and Yoshi’s Newest Adventure
- Accessibility Blindspot: Why Good Designers Still Create Exclusionary Websites
- Windows 11 Insider Preview Builds: Your Top Questions Answered
- Mobile Qubits: Bridging the Gap Between Manufactured and Atomic Quantum Systems