Rust 1.95.0 Introduces cfg_select! Macro, if-let Guards in Matches, and More
What's New in Rust 1.95.0
The Rust team has released version 1.95.0, bringing a handful of new features and stabilizations that make the language even more expressive and efficient. This release introduces a new cfg_select! macro, extends pattern matching capabilities with if-let guards, and stabilizes a wide range of APIs. If you already have Rust installed via rustup, simply run:

$ rustup update stable
If you haven’t installed Rust yet, head over to the official rustup page to get started. For those eager to test upcoming features, you can switch to the beta or nightly channels with rustup default beta or rustup default nightly—and please report any bugs you find!
cfg_select! Macro: Compile‑Time Configuration Made Simpler
One of the standout additions in Rust 1.95.0 is the cfg_select! macro, which acts as a compile‑time conditional expression. It works much like a match statement but evaluates configuration predicates (like those used with #[cfg()]) at compile time. This fulfills the same purpose as the popular cfg-if crate, but with its own syntax.
Here’s a quick example:
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",
};
The macro expands to the right‑hand side of the first arm whose condition evaluates to true. This makes conditional compilation cleaner and more readable, especially when you have multiple platform‑ or architecture‑specific blocks.
if-let Guards in match Expressions
Building on the let chains stabilised in Rust 1.88, version 1.95.0 now brings if-let guards directly into match expressions. This allows you to combine pattern matching with a conditional that itself performs pattern matching, all within a single arm.
For example:
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 used in if-let guards when checking exhaustiveness—just as with regular if guards. This feature makes code more concise and powerful, especially when dealing with nested results or options.
Stabilized APIs
Rust 1.95.0 also stabilizes a large set of APIs, many of which improve ergonomics around MaybeUninit, Cell, atomics, and collection types. Below is a full list:
Conversions and References for MaybeUninit and Cell Arrays
MaybeUninit<[T; N]>: From<[MaybeUninit<T>; N]>MaybeUninit<[T; N]>: AsRef<[MaybeUninit<T>; N]>MaybeUninit<[T; N]>: AsRef<[MaybeUninit<T>]>MaybeUninit<[T; N]>: AsMut<[MaybeUninit<T>; N]>MaybeUninit<[T; N]>: AsMut<[MaybeUninit<T>]>[MaybeUninit<T>; N]: From<MaybeUninit<[T; N]>>Cell<[T; N]>: AsRef<[Cell<T>; N]>Cell<[T; N]>: AsRef<[Cell<T>]>Cell<[T]>: AsRef<[Cell<T>]>
Atomic Operations
bool: TryFrom<{integer}>AtomicPtr::updateAtomicPtr::try_updateAtomicBool::updateAtomicBool::try_updateAtomicIn::updateAtomicIn::try_updateAtomicUn::updateAtomicUn::try_update
New Modules and Core Additions
cfg_select!(macro)mod core::rangecore::range::RangeInclusivecore::range::RangeInclusiveItercore::hint::cold_path
Pointer Methods
<*const T>::as_ref_unchecked<*mut T>::as_ref_unchecked<*mut T>::as_mut_unchecked
Collection Mutability Enhancements
Vec::push_mutVec::insert_mutVecDeque::push_front_mutVecDeque::push_back_mutVecDeque::insert_mutLinkedList::push_front_mutLinkedList::push_back_mut
Get Started with Rust 1.95.0
To upgrade, simply run rustup update stable. For full details, check the detailed release notes. As always, the Rust community welcomes your feedback and contributions—happy coding!
Related Articles
- REZ Transmission Line Rerouted to Protect Caves, Secures Support from 50 Additional Landowners
- How to Create Custom Wallet Passes in iOS 27: A Step-by-Step Guide
- Understanding Roblox's User Decline: Age Verification and Its Impact
- Exploring HASH: Build Interactive Simulations to Decode Complex Systems
- AWS Advances Autonomous Operations with General Availability of DevOps and Security Agents, Plus Key Service Lifecycle Changes
- Microsoft Assures Users: Extra Restart During Windows 11 Updates is Normal, Not a Failure
- How to Manage macOS Updates Securely Without Dangerous Delays
- How to Decode the Pixel 11 Leak: Tensor G6, Camera, and Pixel Glow Discovered