Rust 1.95.0: What's New in the Latest Stable Release
Rust 1.95.0 Now Available
The Rust team has released version 1.95.0 of the Rust programming language, bringing new features and improvements to enhance developer productivity and code reliability. This update introduces a compile-time conditional macro, extends pattern matching capabilities, and stabilizes a wide range of APIs. Users can upgrade via rustup update stable if they already have Rust installed. For those new to Rust, visit the official installation page to get started. Developers interested in testing upcoming releases can switch to the beta channel (rustup default beta) or nightly channel (rustup default nightly) and report any bugs encountered.

New Compile-Time Conditional Macro: cfg_select!
Rust 1.95.0 introduces the cfg_select! macro, which provides a convenient way to choose code branches at compile time based on configuration predicates. This macro functions similarly to a match expression on cfg attributes, fulfilling the same purpose as the popular cfg-if crate but with a different syntax. The macro expands to the right-hand side of the first arm whose condition evaluates to true. Here are some examples:
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",
};
This macro simplifies conditional compilation by allowing multiple conditions to be evaluated in a single expression, improving code readability and maintainability.
Enhanced Pattern Matching with if let Guards
Building on the let chains stabilized in Rust 1.88, version 1.95.0 brings similar functionality to match expressions. Developers can now use if let guards within match arms to run additional pattern matching conditionally. This enables more expressive control flow:
match value {
Some(x) if let Ok(y) = compute(x) => {
// Both `x` and `y` are available here
println!("{}, {}", x, y);
}
_ => {}
}
Note that the compiler currently does not consider patterns matched in if let guards as part of exhaustiveness checking, similar to regular if guards. This feature expands the versatility of pattern matching without sacrificing clarity.
Stabilized APIs and Improvements
Rust 1.95.0 stabilizes a significant number of APIs across standard library types, including conversions and references for MaybeUninit, Cell, and atomic types. Key additions include:
- MaybeUninit arrays: New
From,AsRef, andAsMutimplementations forMaybeUninit<[T; N]>and[MaybeUninit<T>; N]. - Cell arrays and slices:
AsRefimplementations forCell<[T; N]>andCell<[T]>. - Boolean conversion:
bool: TryFrom<{integer}>allows safe conversion from integers. - Atomic operations: New
updateandtry_updatemethods forAtomicPtr,AtomicBool, andAtomicIn/AtomicUn(likely referring toAtomicI/AtomicUtypes, as per original). These facilitate atomic read-modify-write patterns. - Range module: The new
core::rangemodule providesRangeInclusiveand its iterator. - Hint for cold paths:
core::hint::cold_pathhelps optimize branch prediction. - Pointer methods:
as_ref_uncheckedandas_mut_uncheckedfor raw pointers eliminate some safety boilerplate. - Collection mutations:
Vec::push_mut,Vec::insert_mut, and similar methods forVecDequeandLinkedListallow direct mutation of elements returned by index.
These additions enhance ergonomics and safety across common programming patterns.
How to Get Started with Rust 1.95.0
To upgrade your existing installation, run rustup update stable. If you are new to Rust, install rustup from the official website and follow the instructions. For a complete list of changes, consult the detailed release notes. As always, report any issues on the Rust issue tracker to help improve the language.
Related Articles
- Tech Giants Agree to Pre-Release AI Safety Audits by Commerce Department
- How to Experience Skywind: Transforming Skyrim into Morrowind
- Unraveling Complexity: How Simulation Modeling with HASH Unlocks Hidden Insights
- Beyond GPS: Your Step-by-Step Guide to Understanding Global Navigation Satellite Systems
- Reviving the Humane Ai Pin: How Hacks Turn a Discontinued Wearable into a Standalone Android Device
- 6 Key Insights Into the Daemon Tools Supply-Chain Attack
- Maximize Productivity: Unlock Microsoft 365 with AI and 1TB Storage at a Discount
- Mastering USB Drop Attacks: A Penetration Tester's Guide to Social Engineering