Quick Facts
- Category: Technology
- Published: 2026-05-02 08:10:18
- Deploy a Full-Stack Next.js App on Cloudflare Workers: Complete CI/CD Guide Using GitHub Actions
- British Hacker Behind Tech Giants Phishing Spree Pleads Guilty
- Mastering Modern Web Experiments: HTML in Canvas, Hex Maps, E-ink Tweaks, and CSS Image Sorcery
- 10 Key Facts About Russia's Soyuz 5 Rocket After Its Successful Debut
- Docker Offload Reaches General Availability: Unlocking Container Power for Every Developer, Everywhere
Rust 1.95.0 has arrived, and it's packed with features that elevate the language's expressiveness, safety, and performance. Whether you're a systems programmer or a web developer, these five updates—from a new compile-time macro to enhanced standard library capabilities—will simplify your code and unlock new patterns. Let's dive into what makes this release special.
1. The cfg_select! Macro: Compile-Time Branching Reimagined
Rust 1.95 introduces cfg_select!, a macro that acts like a compile-time match for configuration predicates. It expands to the right-hand side of the first arm whose condition evaluates to true. This eliminates the need for the popular third-party cfg-if crate in many cases. For example:

cfg_select! {
unix => { fn foo() { /* unix specific */ } }
target_pointer_width = "32" => { fn foo() { /* 32-bit */ } }
_ => { fn foo() { /* fallback */ } }
}
let os = cfg_select! {
windows => "windows",
_ => "not windows",
};
This macro supports arbitrary cfg predicates and a wildcard _ arm. Its syntax is cleaner and more flexible than nested #[cfg] attributes, making platform-specific code more readable. It's particularly useful for library authors who need to support multiple targets without messy conditionals.
2. If-let Guards in Match Expressions: Pattern Matching on Steroids
Building on the let chains stabilised in Rust 1.88, version 1.95 brings if let guards to match arms. This lets you combine pattern matching with additional conditions that themselves involve pattern matching. For example:
match value {
Some(x) if let Ok(y) = compute(x) => {
println!("{}, {}", x, y);
}
_ => {}
}
The guard if let Ok(y) = compute(x) succeeds only when compute(x) returns Ok, binding the inner value to y. Note that the compiler currently does not consider these guards in exhaustiveness checking—a known limitation that may be improved in future releases. This feature enables more concise and expressive handling of nested results or options.
3. MaybeUninit and Cell Array Conversions: Safer Zero-Cost Abstractions
Several trait implementations for MaybeUninit and Cell arrays are now stable, making it easier to convert between arrays of uninitialised values and single MaybeUninit arrays, and to get array references from Cell slices. For instance:
MaybeUninit<[T; N]>: From<[MaybeUninit<T>; N]>Cell<[T; N]>: AsRef<[Cell<T>; N]>andAsRef<[Cell<T>]>bool: TryFrom<{integer}>for safe conversion.
These additions reduce the need for unsafe code when working with uninitialised memory or interior mutability. They enable safe, ergonomic patterns for low-level data structures, while maintaining Rust's zero-cost abstraction promise. The TryFrom implementation for bool provides a fallible way to convert integers to booleans, catching invalid values at runtime.
4. Atomic Operations Get update and try_update Methods
Atomic types like AtomicPtr, AtomicBool, and the integer atomics now provide update and try_update methods. These allow you to atomically modify the value using a closure, similar to fetch_update but with a more ergonomic interface. For example:
use std::sync::atomic::{AtomicU32, Ordering};
let counter = AtomicU32::new(0);
counter.update(|x| x + 1, Ordering::SeqCst);
The update method loops until the operation succeeds, while try_update attempts once and returns Err if the CAS fails. These methods simplify concurrent programming by reducing boilerplate. They are available on all stable atomic types (except AtomicBool for update/try_update—it uses a slightly different signature). This enhancement makes lock-free algorithms more accessible.
5. core::range Module and Collection Convenience Methods
Rust 1.95 stabilises the core::range module, which includes types for range expressions: RangeInclusive and RangeInclusiveIter. These provide more flexibility when working with inclusive ranges. Additionally, several collections gain mutable insertion and push methods:
Vec::push_mutandVec::insert_mutVecDeque::push_front_mut,push_back_mut, andinsert_mutLinkedList::push_front_mut
These methods return a mutable reference to the inserted element, enabling chainable operations. For example: v.push_mut(item).do_something(). The cold_path hint (core::hint::cold_path) is also stabilised, helping optimisers with branch prediction. Together, these additions improve ergonomics and performance tuning.
Rust 1.95.0 is available now via rustup update stable. If you haven't installed Rust yet, head to rustup.rs to get started. For a complete list of changes, see the detailed release notes. Happy coding!