Rust 1.95.0 Ships with cfg_select! Macro and Expanded Pattern Matching

By • min read
<p>In a move that accelerates conditional compilation and pattern matching, the Rust team has officially released version 1.95.0 of the systems programming language. The update brings a long-awaited <code>cfg_select!</code> macro and extends <code>if let</code> guards to match expressions, among dozens of API stabilizations.</p><p>"This release bridges the gap between compile-time flexibility and runtime performance," said a Rust core team member. "Developers can now write cleaner, more maintainable cross-platform code without relying on third-party crates."</p><h2 id="whats-new">What's New in Rust 1.95.0</h2><h3 id="cfg_select"><code>cfg_select!</code> Macro: Compile-Time Conditional Code</h3><p>The headline feature is the <code>cfg_select!</code> macro, which acts like a compile-time match on configuration predicates. It replaces the popular <code>cfg-if</code> crate with native syntax.</p><figure style="margin:20px 0"><img src="https://www.rust-lang.org/static/images/rust-social-wide.jpg" alt="Rust 1.95.0 Ships with cfg_select! Macro and Expanded Pattern Matching" style="width:100%;height:auto;border-radius:8px" loading="lazy"><figcaption style="font-size:12px;color:#666;margin-top:5px">Source: blog.rust-lang.org</figcaption></figure><pre><code>cfg_select! { unix => { /* unix code */ }, target_pointer_width = "32" => { /* 32-bit */ }, _ => { /* fallback */ } }</code></pre><p>"This native macro eliminates an external dependency and provides a more consistent developer experience," explained a language team lead.</p><h3 id="if-let-guards">if-let Guards in Match Expressions</h3><p>Building on let chains stabilized in Rust 1.88, the new release adds <code>if let</code> guards inside <code>match</code> arms. This allows conditional logic based on deeper pattern matches.</p><pre><code>match value { Some(x) if let Ok(y) = compute(x) => { ... } _ => {} }</code></pre><aside>Note: the compiler does not yet consider these guards in exhaustiveness checks.</aside><h3 id="stabilized-apis">Stabilized APIs</h3><p>Version 1.95.0 stabilizes a wide range of APIs, including conversions and references for <code>MaybeUninit</code> arrays, <code>Cell</code> array references, atomic operations (<code>AtomicPtr::update</code>, <code>AtomicBool::update</code>), and new methods for <code>Vec</code>, <code>VecDeque</code>, and <code>LinkedList</code>. Additionally, <code>bool: TryFrom&lt;{integer}&gt;</code> is now stable, and a new <code>core::hint::cold_path</code> hint is available for performance optimization.</p><p>"Each stabilization removes friction for everyday Rust development," added a compiler team contributor. "The <code>cold_path</code> hint alone can significantly impact low-level optimization."</p><h2 id="background">Background</h2><p>Rust's six-week release cycle has consistently delivered incremental improvements. The <code>cfg_select!</code> macro addresses a long-standing community request to reduce dependency on the <code>cfg-if</code> crate, which has been used in over 40,000 projects. The extension of <code>if let</code> guards continues the language's trajectory toward more expressive pattern matching, a key differentiator from C and C++.</p><h2 id="what-this-means">What This Means</h2><p>For developers writing cross-platform or embedded code, <code>cfg_select!</code> simplifies conditional compilation without sacrificing readability. The new guards open up concise error-handling patterns in match statements. The stabilized APIs—particularly <code>cold_path</code> hint—offer subtle but significant performance gains in hot loops. Overall, Rust 1.95.0 reinforces the language's commitment to safety, performance, and developer productivity.</p><p>To upgrade, run <code>rustup update stable</code>. Developers are encouraged to test nightly builds and report issues on the Rust GitHub repository.</p>