Rust 1.95.0: New Macro, Enhanced Pattern Matching, and More
The Rust team is pleased to announce the release of Rust 1.95.0, the latest stable version of the language that empowers developers to build reliable and efficient software. This release introduces a new compile-time selection macro, extends pattern matching capabilities in match expressions, and stabilizes a significant number of APIs. If you already have Rust installed via rustup, you can update with:
rustup update stableFor those new to Rust, get rustup from the official website. The full release notes are available here. If you'd like to test upcoming features, switch to the beta or nightly channels (rustup default beta or rustup default nightly) and report any bugs you encounter.
New cfg_select! Macro
Rust 1.95.0 introduces the cfg_select! macro, which acts as a compile-time conditional selection tool. It resembles the popular cfg-if crate but with its own syntax. The macro evaluates configuration predicates sequentially and expands to the right-hand side of the first arm that evaluates to true. Here is an example of its usage with functions:

cfg_select! {
unix => {
fn foo() { /* unix specific functionality */ }
}
target_pointer_width = "32" => {
fn foo() { /* non-unix, 32-bit functionality */ }
}
_ => {
fn foo() { /* fallback implementation */ }
}
}You can also use it inline, as in this string assignment:
let is_windows_str = cfg_select! {
windows => "windows",
_ => "not windows",
};This macro simplifies conditional compilation by eliminating the need for external crates or repetitive cfg! checks, making code more concise and readable.
Enhanced Pattern Matching with if-let Guards
Building on the let chains stabilized in Rust 1.88, version 1.95.0 brings if let guards into match expressions. This allows you to add pattern-matching conditions directly in match arms. 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 matched in if let guards as part of exhaustiveness checks—similar to regular if guards. This feature enhances expressiveness by allowing complex conditional destructuring without nesting additional match or if let statements.
Stabilized APIs
Rust 1.95.0 stabilizes a wide range of APIs, many of which improve ergonomics for MaybeUninit, Cell, atomics, pointers, and collections. Here are the highlights:
Conversions and References for MaybeUninit
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]>>
Reference Implementations for Cell
Cell<[T; N]>: AsRef<[Cell<T>; N]>Cell<[T; N]>: AsRef<[Cell<T>]>Cell<[T]>: AsRef<[Cell<T>]>
Type Conversions and Atomic Operations
bool: TryFrom<{integer}>— Convert integer types toboolwith error handling.- Atomic pointer and boolean update methods:
AtomicPtr::update,AtomicPtr::try_update,AtomicBool::update,AtomicBool::try_update. - Atomic integer updates:
AtomicIn::update,AtomicIn::try_update,AtomicUn::update,AtomicUn::try_update(whereInandUnrepresent signed and unsigned integer types).
Core and Collections
cfg_select!macro (now stabilized).- New module
core::rangewith typesRangeInclusiveandRangeInclusiveIter. - New hint function
core::hint::cold_pathto guide the optimizer. - Pointer methods:
<*const T>::as_ref_unchecked,<*mut T>::as_ref_unchecked,<*mut T>::as_mut_unchecked. - Collection mutations:
Vec::push_mut,Vec::insert_mut,VecDeque::push_front_mut,VecDeque::push_back_mut,VecDeque::insert_mut,LinkedList::push_front_mut.
These additions improve safety, ergonomics, and performance for low-level and high-level Rust code alike.
Conclusion
Rust 1.95.0 continues the language's tradition of incremental improvement. With the cfg_select! macro, if-let guards in match arms, and a robust set of stabilized APIs, developers gain powerful tools for writing clean, efficient, and context-aware code. Update your toolchain today and explore the new possibilities.
Related Articles
- Exploring Gemini is rolling out to cars with Google built-in
- 10 Key Updates in Safari Technology Preview 242 You Should Know About
- The Quantum Countdown: 5 Critical Facts About the Imminent Crypto Apocalypse
- Microsoft Restructures Windows Insider Program: New Channels and Feature Selection in Latest Builds
- Stack Overflow Co-Founder Jeff Atwood Mourns Father, Warns AI Companies Not to ‘Kill the Goose That Lays the Golden Eggs’
- Breaking: Next-Gen MacBook Pro with OLED and Redesign Delayed; Analysts Urge Patience on Current M5 Models
- Your Ultimate Guide to the 2027 iPhone’s Solid-State Buttons and Curved Glass Design
- Apple Abandons Vision Pro, Eyes MacBook Ultra and Foldable iPhone Ultra in Major Strategy Shift