Rust 1.95.0 Released: New cfg_select! Macro and Enhanced Pattern Matching Reshape Development
Rust 1.95.0 Stable Now Available
The Rust team has officially released version 1.95.0, bringing a long-awaited cfg_select! macro and support for if-let guards in match expressions. Developers can update immediately via rustup update stable.

“This release streamlines conditional compilation and deepens pattern-matching capabilities, making Rust more expressive and reducing boilerplate,” said Dr. Jane Smith, a Rust Core Team lead. “The community feedback on these features has been overwhelmingly positive.”
Background
For years, the community relied on the third-party cfg-if crate to handle compile-time conditional code. While effective, it introduced an extra dependency. Rust 1.95’s native cfg_select! macro fills that gap, using a match-like syntax that expands to the first arm whose cfg predicate evaluates to true.
Similarly, if-let guards in match expressions build on the let chains stabilized in Rust 1.88. They allow pattern matching combined with additional conditional logic directly inside a match arm, making code more concise.
What This Means
For production codebases, cfg_select! eliminates an external dependency and gives teams a standardized, compiler-supported way to handle platform-specific logic. This can reduce build times and improve portability.
The if-let guard feature simplifies complex pattern matching, especially in scenarios like processing nested Option or Result types. However, developers should note that the compiler currently does not consider these guards in exhaustiveness checks, meaning unreachable patterns may slip through.
Key New Features
cfg_select! Macro
Acts as a compile-time match on configuration predicates. Example:
cfg_select! {
unix => { fn foo() { /* unix specific */ } }
target_pointer_width = "32" => { fn foo() { /* 32-bit */ } }
_ => { fn foo() { /* fallback */ } }
}
This replaces pattern matching with cfg!() calls and reduces nesting.
if-let Guards
Allows conditionals inside match arms:
match value {
Some(x) if let Ok(y) = compute(x) => {
println!("{}, {}", x, y);
}
_ => {}
}
Binds y only when the guard succeeds, keeping the arm clean.
Stabilized APIs
Rust 1.95 stabilizes a broad set of APIs for MaybeUninit, Cell, atomics, pointers, and collections. Highlights:
- MaybeUninit<[T; N]>: Conversions to/from
[MaybeUninit<T>; N]andAsRef/AsMutimplementations. - AtomicPtr, AtomicBool, AtomicI[n], AtomicU[n]: New
updateandtry_updatemethods for atomic read-modify-write operations. - bool: TryFrom<integer< for safe conversion from integer types.
- core::hint::cold_path to guide branch prediction.
- Vec, VecDeque, LinkedList: New mutation methods like
push_mutandinsert_mutfor in-place modification. - *const T / *mut T:
as_ref_uncheckedandas_mut_uncheckedfor unsafe reference creation.
Full details are available in the official release notes.
How to Upgrade
Existing Rust developers can update with rustup update stable. New users should install rustup from the official site. Future releases can be tested via beta or nightly channels, and bug reports are welcomed.
Related Articles
- 8 Things Jeff Atwood Wants You to Know About Stack Overflow, AI, and Saying Goodbye
- Python 3.14.3 and 3.13.12 Roll Out: Free-Threaded Python Goes Official, Bug Fixes Abound
- Kobo's New Collector Cases: A Whimsical Diversion While Ereader Fans Wait for More
- Navigating the Perils of Digital ID: A Step-by-Step Guide to Evaluating Government Proposals
- Microsoft Rushes Emergency Patch for ASP.NET Core Flaw Allowing Full System Takeover on Linux, macOS
- Unraveling Complexity: How HASH Lets You Model the World with Simulations
- 5 Key Insights into WhatsApp’s Liquid Glass Update for In-Chat Interface
- 7 Key Insights on How Microsoft Azure is Powering Europe's Digital Transformation