Rust 1.95.0 Released: Introducing cfg_select! and Improved Pattern Matching
What's New in Rust 1.95.0
The Rust team has announced the release of version 1.95.0, bringing significant enhancements to the language's conditional compilation and pattern matching capabilities. This update focuses on reducing boilerplate while maintaining Rust's core safety guarantees. Developers will find the new cfg_select! macro and improved match expressions particularly valuable for writing cleaner, more maintainable code.

Updating to Rust 1.95.0
If you already have Rust installed via rustup, obtaining the latest stable release is straightforward:
$ rustup update stable
New users can install rustup from the official Rust website. For those interested in testing upcoming features, you can switch to the beta or nightly channels:
$ rustup default beta
$ rustup default nightly
We encourage all users to report any bugs they encounter on the GitHub issue tracker.
The cfg_select! Macro
Conditional compilation has long been a necessity in Rust, especially for cross-platform development. The cfg-if crate has been a popular solution, but Rust 1.95.0 now offers an official alternative: cfg_select!. This macro works like a compile-time match on configuration predicates, expanding to the right-hand side of the first matching arm.
Basic Usage
The macro accepts any number of arms, each consisting of a configuration predicate and a corresponding expression or block:
cfg_select! {
unix => {
fn foo() { /* Unix-specific functionality */ }
}
target_pointer_width = "32" => {
fn foo() { /* 32-bit, non-Unix */ }
}
_ => {
fn foo() { /* fallback */ }
}
}
let is_windows_str = cfg_select! {
windows => "windows",
_ => "not windows",
};
The underscore (_) serves as a catch-all, similar to the default arm in a match expression. This feature streamlines conditional code without relying on external crates.
if-let Guards in Match Expressions
Building on the let chains stabilized in Rust 1.88, version 1.95.0 extends this capability to match expressions. You can now use if let guards to combine pattern matching with conditional logic inside a single match arm:
match value {
Some(x) if let Ok(y) = compute(x) => {
// Both `x` and `y` are available here
println!("{}, {}", x, y);
}
_ => {}
}
This syntax keeps your code concise and expressive, eliminating the need for nested if let statements. Note that the compiler currently does not consider patterns in if let guards when checking exhaustiveness, so you may need to add a wildcard arm.
Stabilized APIs
Rust 1.95.0 stabilizes a number of APIs that improve ergonomics and safety. Here is a categorized overview:
Conversions and References for MaybeUninit and Cell
MaybeUninit<[T; N]>: From<[MaybeUninit<T>; N]>MaybeUninit<[T; N]>: AsRef<[MaybeUninit<T>; N]>andAsRef<[MaybeUninit<T>]>MaybeUninit<[T; N]>: AsMut<[MaybeUninit<T>; N]>andAsMut<[MaybeUninit<T>]>[MaybeUninit<T>; N]: From<MaybeUninit<[T; N]>>Cell<[T; N]>: AsRef<[Cell<T>; N]>andAsRef<[Cell<T>]>Cell<[T]>: AsRef<[Cell<T>]>
Integer to Boolean Conversion
bool: TryFrom<{integer}>
Atomic Operations
AtomicPtr::updateandAtomicPtr::try_updateAtomicBool::updateandAtomicBool::try_updateAtomicIn::updateandAtomicIn::try_updateAtomicUn::updateandAtomicUn::try_update
Core Range and Hint
mod core::rangewithcore::range::RangeInclusiveandcore::range::RangeInclusiveItercore::hint::cold_path
Raw Pointer Safety
<*const T>::as_ref_unchecked<*mut T>::as_ref_uncheckedand<*mut T>::as_mut_unchecked
Collection Mutators
Vec::push_mutandVec::insert_mutVecDeque::push_front_mut,VecDeque::push_back_mut, andVecDeque::insert_mutLinkedList::push_front_mut
For a complete list, refer to the detailed release notes.
Conclusion
Rust 1.95.0 continues the language's tradition of empowering developers with safe, efficient tools. The cfg_select! macro reduces reliance on third-party crates, while if-let guards in match expressions make pattern matching more flexible. Combined with the newly stabilized APIs, this release is a solid step forward for the ecosystem. Update today and give these features a try!
Related Articles
- Silent Tech Failures Drain Millions in Lost Productivity, Study Reveals
- Swift System Metrics 1.0: A Comprehensive Guide to Process-Level Monitoring
- Cloudflare’s Vision for the Agentic Cloud: A Recap of Agents Week 2026
- Urgent: Critical ASP.NET Zero-Day Allows Full System Takeover on Linux, macOS
- Microsoft Assures Users: Extra Restart During Windows 11 Updates is Normal, Not a Failure
- XPENG Sales Surge 44.7% After VLA 2.0 Launch: Key Questions Answered
- Unlocking the Potential of Electronic Shelf Labels with TagTinker
- A Look at Xbox owners can now disable Quick Resume for specific games